javascript 改变select 的选项

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题 1</title>
<script type="text/javascript"  src="Scripts/jquery-1.4.1-vsdoc.js"></script>
</head>
<body>
<form method="post">
 <select id="s2" name="Select1">
 <option value="0"></option>
 <option value="1">11</option>
 <option value="2">22</option>
 <option value="3">33</option>
 </select></form>
</body>
<script  type="text/javascript" defer="defer">
    var doms = document.getElementsByTagName("select");
    //doms[0].value="1";

    //doms[0].options[2].selected = true;

    //jquery方法
    $("#s2 option[index=3]").attr("selected", true)
</script>
</html>

posted @ 2012-05-20 20:26  Bug山Bug海  阅读(423)  评论(0编辑  收藏  举报