To remove an item from a select box with JavaScript, we use the remove
method.
For instance, we write
<select name="selectBox" id="selectBox">
<option value="option1">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
<option value="option4">option4</option>
</select>
to add the select drop down.
Then we write
document.querySelector("#selectBox option[value='option1']").remove();
to select the option element in the drop down with the value
attribute set to option1
with querySelector
.
And then we call remove
to remove the option.