实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script>
5
function getIndex()
6
{
7
var x=document.getElementById("mySelect");
8
alert(x.selectedIndex);
9
}
10
</script>
11
</head>
12
<body>
13
14
<form>
15
你喜欢的水果是:
16
<select id="mySelect">
17
  <option>Apple</option>
18
  <option>Orange</option>
19
  <option>Pineapple</option>
20
  <option>Banana</option>
21
</select>
22
<br><br>
23
<input type="button" onclick="getIndex()" value="弹出选中项">
24
</form>
25
26
</body>
27
</html>         
28