獲取下拉框的改變以及改變的value

<html>
<head>
<script type="text/javascript">
function changeText()
{
    var x=document.getElementById("mySelect");
    alert(x.options[x.selectedIndex].text);
}
</script>
</head>
<body>

<form>
    Select your favorite fruit:
    <select id="mySelect" οnchange="changeText()">
       <option>Apple</option>
       <option>Orange</option>
       <option>Pineapple</option>
       <option>Banana</option>
    </select>
</form>

</body>
</html>

也歡迎登錄我的個人網站,裏面有更多的文章及技術諮詢在等你:http://www.guangmuhua.com

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章