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 = "";
如果使用的是jQuery,请选择以下选项:
$("#selectboxID").empty();
Thanks for the quick reply How about this?? document.getElementById(id).options.length = 0;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.