欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

HTML DOM remove() 方法

定義和用法

remove() 方法用于從下拉列表刪除選項。

語法

selectObject.remove(index)
參數(shù) 描述
index 必需。規(guī)定要刪除的選項的索引號。

說明

該方法從選項數(shù)組的指定位置移除 <option> 元素。如果指定的下標比 0 小,或者大于或等于選項的數(shù)目,remove() 方法會忽略它并什么也不做。

實例

下面的例子可從列表中刪除被選的選項:

<html>
<head>
<script type="text/javascript">
function removeOption()
  {
  var x=document.getElementById("mySelect")
  x.remove(x.selectedIndex)
  }
</script>
</head>
<body>

<form>
<select id="mySelect">
  <option>Apple</option>
  <option>Pear</option>
  <option>Banana</option>
  <option>Orange</option>
</select>
<input type="button" onclick="removeOption()"
value="Remove option">
</form>

</body>
</html>