Reputation: 7577
I want to select elements that have similar incrementally-based names. Is there shorter notation to do the same thing?
$('#galnav1,#galnav2,#galnav3,#galnav4,#galnav5,#galnav6,#galnav7,#galnav8,#galnav9,').each(function(){
...
});
Upvotes: 1
Views: 36
Reputation: 254916
How about this one:
$('[id^=galnav]');
$('[id^=galnav]').filter(function() {
return /v\d$/.test($(this).attr('id'));
});
Upvotes: 5
Reputation: 6955
You can use this jquery selector
$('[id^="galnav"]').each(function(){
...
});
Upvotes: 1