Reputation: 10078
I have a set of links:
<div id="parent">
<a id="UserFirst" href="#"></a>
<a id="UserSecond" href="#"></a>
<a id="UserThird" href="#"></a>
</div>
I need a quick way of getting (for example) all the a
children of #parent
, whose ID contains the letter i
.
How can I do it?
Upvotes: 5
Views: 23082
Reputation: 298432
Use an attribute selector:
a[id*="i"]
Or .filter()
:
$('a').filter(function() {
return this.id.indexOf('a') !== -1;
});
Upvotes: 3
Reputation: 20313
Use jquery contains selector
:
$("#parent").find("a[id*='i']").each(function(){
//do something here
});
Upvotes: 14