Reputation: 135
I have the following html:
input id="abc_0_1"
input id="rub_0_1"
input id="rub_0_2"
input id="rub_1_1"
input id="rub_1_2"
input id="rub_2_1"
input id="rub_2_1"
input id="abc_4_5"
Using jQuery I want to select only the inputs that start with 'rub_' but do not start with 'rub_0'
How can I do it, assuming I have much more inputs with similar ids?
Thanks,
Avi
Upvotes: 0
Views: 264
Reputation: 85573
Use like this:
$('[id^="rub_"]:not('[id^="rub_0"]')
Or, like this:
$('[id^="rub_"]).filter(function(){
return $(this).not('[id^="rub_0"]);
})
more details on attribute selector
Upvotes: 0
Reputation: 388416
You can use attribute starts with selector and not selector
var $els = $('input[id^="rub_"]:not([id^="rub_0"])')
Upvotes: 5