ड्रॉपडाउन सूची से विकल्पों को हटाने के लिए, जावास्क्रिप्ट में निकालें () विधि का उपयोग करें। ड्रॉप-डाउन से विकल्पों को निकालने का तरीका जानने के लिए आप निम्न कोड चलाने का प्रयास कर सकते हैं -
उदाहरण
<!DOCTYPE html>
<html>
<body>
<form id = "myForm">
<select id = "selectNow">
<option>One</option>
<option>Two</option>
<option>Three</option>
</select>
<input type = "button" onclick = "remove()" value = "Click to Remove">
</form>
<p>Select and click the button to remove the selected option.</p>
<script>
function remove() {
var x = document.getElementById("selectNow");
x.remove(x.selectedIndex);
}
</script>
</body>
</html>