[select.selectedIndex] 獲取到選中的 option 元素。
故,獲得當前 select 元素值的腳本如下:
![程序代碼](http://www.wowbox.com.tw/blog/images/code.gif)
var getSelectValue = funtion(select) {
var idx = select.selectedIndex,
option,
value;
if (idx > -1) {
option = select.options[idx];
value = option.attributes.value;
return (value && value.specified) ? option.value : option.text);
}
return null;
}
var idx = select.selectedIndex,
option,
value;
if (idx > -1) {
option = select.options[idx];
value = option.attributes.value;
return (value && value.specified) ? option.value : option.text);
}
return null;
}
原文:需要點這裡...
文章提供: BAYSTARS DESIGN網頁設計公司
全站熱搜