实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<script>
5
function removeOption()
6
{
7
var x=document.getElementById("mySelect");
8
x.remove(x.selectedIndex);
9
}
10
</script>
11
</head>
12
<body>
13
14
<form>
15
<select id="mySelect">
16
  <option>Apple</option>
17
  <option>Pear</option>
18
  <option>Banana</option>
19
  <option>Orange</option>
20
</select>
21
<input type="button" onclick="removeOption()" value="Remove selected option">
22
</form>
23
24
</body>
25
</html>