Select remove()Methods
Select Object
Definition and Usage
The remove() method is used to delete options from a drop-down list.
Syntax
selectObject.remove(index)
| Parameter | Description |
|---|---|
| index | Required. Specifies the index number of the option to be removed. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the remove() method.
Example
Example
The following example removes the selected option from the list:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</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>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</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>
Try it Yourself »
More Examples
Remove the last option from the drop-down list.
Select Object Other Extensions