Can anyone please explain why jQuery works on the original code but deletes all the option for my code.
var i=0;
var cursel = "#mySelect".concat(i);
$(cursel).children().remove("optgroup");
Original Code: http://jsfiddle.net/frJEq/
My Code: http://jsfiddle.net/frJEq/43/
I have multiple of the exact same select menu so that's why I have it setup for the concat to put in the counter. But why does it work for the original and not mine? I have been pouring over code and examples and can't see why.
It does run. Most of your options are inside optgroup elements, so they get removed. Try moving the options outside of the optgroup elements, like in your "original code" snippet.
What you want to do is use the unwrap method:
$(cursel).children('optgroup').children().unwrap();