Easy Tutorial
❮ Prop Style Bordertopstyle Prop Link Media ❯

Select remove() Method


Definition and Usage

The remove() method is used to remove an option from a dropdown list.

Syntax

Parameter Description
index Required. Specifies the index number of the option to be removed.

Browser Support

All major browsers support the remove() method.


Example

The following example removes the selected option from the list:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
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>

More Examples

Remove the last option from the dropdown list

❮ Prop Style Bordertopstyle Prop Link Media ❯