<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jquery操作select</title>
<script type="text/javascript" src="../js2/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//修改option中的内容
//$("#select option:first").html("被修改了");
//获取被选中的option中的内容
// $("#click").click(function () {
// alert($("#select").find("option:checked").text());
// alert($("#select option:checked").text());
//
// });
// 获取被选中的option中值
// $("#click").click(function () {
// alert($("#select option:checked").val());
//
// })
// $("#click").click(function () {
// 获取Select选择的索引值
// alert($("#select").get(0).selectedIndex);
//
// });
//为Select追加一个Option(下拉项)
// $("#click").click(function () {
// $("#select").append("<option value='zhengzhou'>郑州</option>");
//
// })
//为Select插入一个Option(第一个位置)
// $("#click").click(function () {
// $("#select").prepend("<option value='zhengzhou'>郑州</option>");
//
// })
//删除Select中Value='beijing'的Option
// $("#click").click(function () {
// $("#select option[value='beijing']").remove();
//
// });
// $("#click").click(function () {
// //内容清空:
// $("#select").empty();
// });
});
</script>
</head>
<body>
<input id="click" type="button" value="点击">
<select id="select" name="city">
<option value="beijing">北京</option>
<option value="shanghai">上海</option>
<option value="guangzhou">广州</option>
</select>
</body>
</html>
$(".select")
.change(
function () {
var newssorts = $(this).find("option:selected").val();
window.location.href = "${request.contextPath}/admin/news_all?newssorts=" + newssorts;
});