日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

this.options[selectedIndex]的使用

發布時間:2023/11/27 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 this.options[selectedIndex]的使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<select id="sel" οnchange="javascript:getSelect();">
<option value="a">選擇</option>
<option value="bdd">be</option>
<option value="c">ce</option>
<option value="d">de</option>
<option value="e">ee</option>
</select>
<script>
function getSelect() {//得到select下拉列表中option的valuevar optionValue = document.getElementById("sel").options[document.getElementById("sel").options.selectedIndex].value;//得到select下拉列表中option的textvar optionText = document.getElementById("sel").options[document.getElementById("sel").options.selectedIndex].text; 
}
</script><select id="sele" οnchange="javascript:getE();">
<option value="monday">星期一</option>
<option value="tuesday">星期二</option>
<option value="wednesday">星期三</option>
<option value="thursday">星期四</option>
<option value="friday">星期五</option>
</select>
<script>
function getE() {//我建議這里也像下面一些寫,雖然這樣寫也可以獲得數據var optionsValue = document.getElementById("sele").value;alert(optionsValue);var optionsText = document.getElementById("sele").options[document.getElementById("sele").options.selectedIndex].text;alert(optionsText);
}
</script>

轉載于:https://www.cnblogs.com/moqiang02/p/4061625.html

總結

以上是生活随笔為你收集整理的this.options[selectedIndex]的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。