<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <script type="text/javascript" src="xxx.js"></script> </head> <body> <select id="select"> <option>請選擇項</option> <option>dasfasdf</option> <option>123</option>
</select> </body></html>
?
function $(id){ return document.getElementById(id);}
window.onload = function(){ $('select').options[0].selected=true; $('select').onchange=function(){ var objselect=$('select'); var indexselect=objselect.selectedIndex; var valselect=objselect.options[indexselect].value; alert(valselect);
} }
?
在IE8、9、10下都能正常運行,chrome下也沒問題,就IE7不行,讀取出來的數據為空,IE6未嘗試,不過估計跟IE7一個樣
麻煩誰幫忙解決下
IE7下js讀取select選取項值的問題
LEATH
2018-12-07 03:19:14