หากต้องการลบตัวเลือกออกจากรายการดรอปดาวน์ ให้ใช้เมธอด Remove() ใน JavaScript คุณสามารถลองใช้รหัสต่อไปนี้เพื่อเรียนรู้วิธีลบตัวเลือกจากเมนูแบบเลื่อนลง -
ตัวอย่าง
<!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>