My code works in IE but breaks in Safari, Firefox, and Opera. (big surprise)
document.getElementById("DropList").options.length=0;
After searching, I've learned that it's the length=0
that it doesn't like.
I've tried ...options=null
and var clear=0; ...length=clear
with the same result.
I am doing this to multiple objects at a time, so I am looking for some lightweight JS code.
Try
Or maybe look into the removeChild() function.
Or if you use jQuery framework.
This is the best way :
with PrototypeJS :
I think that is the best sol. is
This is a bit modern and pure JavaScript
document.querySelectorAll('#selectId option').forEach(option => option.remove())