DOM操作表单(select下拉选框)

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
</head>

<body>
<select id="city" name="city" size="5">
<option value="CD">成都</option>
<option value="CQ">重庆</option>
<option value="GY" selected="selected">贵阳</option>
<option value="XZ">西藏</option>
<option value="XJ">新疆</option>
</select>
<input type="button" value="one" onclick="show(myselect.options[0]);" />
<input type="button" value="two" onclick="show(myselect.options[myselect.selectedIndex-1]);" />
<input type="button" value="three" onclick="show(myselect.options[myselect.selectedIndex+1]);" />
<input type="button" value="four" onclick="show(myselect.options[myselect.length-1]);" />
</body>
<script>
var myselect = document.getElementById('city');
var show = function(city) {
alert(city.text);
}
</script>

</html>

原文地址:https://www.cnblogs.com/youcandomore/p/7235194.html