案例:javascript案例     状态:可编辑再运行    进入横版
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
function alertDefaultSelected()
5
{
6
  var x=document.getElementById("mySelect").selectedIndex;
7
  var y=document.getElementsByTagName("option");
8
  alert("Is " + y[x].text + " selected by default? " + y[x].defaultSelected);
9
}
10
</script>
11
</head>
12
<body>
13
14
<form>
15
Select your favorite fruit:
16
<select id="mySelect">
17
  <option>Apple</option>
18
  <option>Orange</option>
19
  <option selected="selected">Pineapple</option>
20
  <option>Banana</option>
21
</select>
22
<br />
23
<br />
24
<input type="button" onclick="alertDefaultSelected()" value="Is the chosen fruit selected by default?">

 运行结果 
 北美留学生论坛