to keep this short and simple, I have a select menu where I am constantly appending and removing elements to a select dropdown. I looked at How do I clear all options in a dropdown box? and Remove values from select list based on condition but had no luck. I am trying to do something like this.
var select = document.getElementById('model-menu');
Now if I do...
select.options //returns an array [with a length of 24]
for (var i = 1; i <= select.options.length; i++) {
select.remove(i)
}
The problem now is that... it only removed half.
select.length //12
It's really wierd. This is where it gets even wierder. If I do...
for (var i = 0; i < select.options.length; i++) {
console.log(i) //24 23 22 21....
}
IT STOPS AT 12.
I am not looking for an exact solution to this problem, but this is some absolute nonsense that I have been dealing with for the past few hours and If someone can direct me to where this issue MIGHT be happening it will save me a lot of stress :)