user1592980 user1592980 - 2 months ago 10
Javascript Question

Can't remove range of options inside multiple select tags

I'm using jQuery and I have a group of select elements saved to servoSelects. Some of them have class "lgServo" and some don't. Of the ones that have that class, I want to remove all the options between index 0 and ~variable~. I don't understand how to do this.


This line of code doesn't work but is it close to what I want?


I don't understand how to do this.

String concatenation:

servoSelects.filter('.lgServo').find('option:gt(0):lt(' + variable = ')');
// --------------------------------------------------^^^^^^^^^^^^^^^^^^^

or possibly slice:

servoSelects.filter('.lgServo').find('option').slice(0, variable).remove();