JS: document.getElementById("sid").value;
Jquery: $("#sid").val();
直接就可以获取指定select的选中的值;
如果是多选的话,需要用其他方法。
alert($("#eID").val()+"/"+document.getElementById("eID").value);
jQuery取select选中的值方法如下:
例子:
<select id="myselect"> <option value="1">Mr</option> <option value="2">Mrs</option> <option value="3">Ms</option> <option value="4">Dr</option> <option value="5">Prof</option></select>jQuery("#myselect option:selected").text(); // => "Mr"还有一点要注意如果 select是checkbox 要这样使用:
jQuery("#select1 option:checked ").text();
JQ 完成这个选择器的核心代码
// Loop through all the selected options