Rumah >hujung hadapan web >tutorial js >javascript获取select的当前值示例代码(兼容IE/Firefox/Opera/Chrome)_javascript技巧
JavaScript获取Select当前值写法:
var value = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;
var text = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].text;
例子: