案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
function removeLastOption()
5
  {
6
  var x=document.getElementById("mySelect")
7
  if (x.length>0)
8
    {
9
    x.remove(x.length-1);
10
    }
11
  }
12
</script>
13
</head>
14
<body>
15
16
<form>
17
<select id="mySelect">
18
  <option>Apple</option>
19
  <option>Pear</option>
20
  <option>Banana</option>
21
  <option>Orange</option>
22
</select>
23
<input type="button" onclick="removeLastOption()" value="Remove last option">
24
</form>
25
26
</body>
27
</html>
28