获取下拉框的改变以及改变的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" onchange="changeText()">
       <option>Apple</option>
       <option>Orange</option>
       <option>Pineapple</option>
       <option>Banana</option>
    </select>
</form>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_25175063/article/details/78950321