如何獲取select下拉框的值:
1.下拉框的option沒(méi)有value屬性時(shí)
復(fù)制代碼 代碼如下:
<select>
<option>學(xué)號(hào)</option>
<option>姓名</option>
<option>年齡</option>
</seclect>
<script>
window.onload = funciton(){
var param = document.getElementById("param1");
param.onchange = getParam(){
var text = param.value;
}
}
</script>
復(fù)制代碼 代碼如下:
<select>
<option>學(xué)號(hào)</option>
<option>姓名</option>
<option>年齡</option>
</seclect>
<script>
window.onload = funciton(){
var param = document.getElementById("param1");
param.onchange = getParam(){
var selectIndex = param.selectIndex; //獲得被選項(xiàng)的引索號(hào)
var text = param.options[selectIndex].text;
</script>
新聞熱點(diǎn)
疑難解答
圖片精選