案例:javascript案例     状态:可编辑再运行    进入横版
x
<input type="button" onclick="getOptions()" value="输出所有选项">
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
function getOptions()
5
  {
6
  var x=document.getElementById("mySelect");
7
  var y="";
8
  for (i=0;i<x.length;i++)
9
    {
10
    y+=x.options[i].text;
11
    y+="<br />";
12
    }
13
  document.write(y);
14
  }
15
</script>
16
</head>
17
18
<body>
19
20
<form>
21
请选择您喜欢的水果:
22
<select id="mySelect">
23
  <option>苹果</option>
24
  <option>桃子</option>

 运行结果 
 北美留学生论坛