欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript獲取select的當(dāng)前值示例代碼(兼容IE/Firefox/Opera/Chrome)

 更新時間:2013年12月17日 09:20:41   作者:  
本篇文章主要介紹了javascript獲取select的當(dāng)前值示例代碼(兼容IE/Firefox/Opera/Chrome) 需要的朋友可以過來參考下,希望對大家有所幫助

JavaScript獲取Select當(dāng)前值寫法:
var value = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;
var text = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].text;

例子:

復(fù)制代碼 代碼如下:

<script>
function check() {
      var select = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;
      alert(select);
}
</script>

<select name="select" id="select">
<option value="test1" selected="selected">Test1</option>
<option value="test2">Test2</option>
</select>
<input type="button" value="我要試試" onclick="check()"/>

相關(guān)文章

最新評論