Reputation: 12605
I'd like to remove a specific option from some select boxes (all with the same values) if their value is "1". The problem is, I'm having difficulty filtering elements down to that specific value.
At the moment, the closest I've got is
$('.demoClass').find('option:contains(1)').remove();
but there are two problems. Firstly, this seems to iterate over the (displayed) contents of the option, not its value...and secondly, it seems to return true the contents contain that value, as opposed to being that value. (Eg contains(1) will return true for (1, 10, 11, 12)...when I want it to return true for "1" only)
In short, what I'm looking to do is find the timeslot option with value X inside all select boxes of class ".demoClass" and remove them. Any suggestions appreciated.
Upvotes: 1
Views: 450
Reputation: 62412
Try this...
$('.demoClass').find('option[value="1"]').remove();
This utilizes the Attribute Equals Selector
Upvotes: 4