I have a dropdown list with more than one thousand items. Once I click on clear button it should clear all items. For removing I tried looping.
What would be the fastest way to remove all items from a dropdown list or listbox?
Set innerHTML of select box as empty string.
var selectBox = document.getElementById("selectboxID");
selectBox.innerHTML = "";
An option if you're using jQuery:
$("#selectboxID").empty();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With