select标签的描述

时间:2023-03-09 20:52:39
select标签的描述

  1、标签html与js如下代码

<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-2.1.0.js"></script>
</head> <body>
<select name="city" id="city_id" onchange="setAct(this)">
<option value="1" code="0531">济南</option>
<option value="2" code="0532">青岛</option>
<option value="3" code="0538">泰安</option>
</select>
<input type="button" name="" onclick="setact()" value="点击测试" />
<script type="text/javascript">
function setact(item){
re = $("#city_id option").toArray() var tmp;
tmp = re[0]
re[0]=re[2]
re[2] = tmp
$("#city_id").html(re)
$("#city_id option[value='2']").attr("selected",true)
$("#city_id option").first().text("贵州")
$("#city_id option").first().val("0")
$("#city_id option[value='3']").attr("selected",false) $("#city_id").val("3"); }
function setAct(itme){
console.log($("#city_id").val())
}
</script> </body> </html>