Reputation: 3287
I've got a HTML structure like this:
<div class="foo">
<ul>
<li>
<a href="link.bar">Good</a>
<ul class="children">
<li>
<a href="otherlink.baz">Bad</a>
</li>
</ul>
</li>
</ul>
</div>
Now I want to select the "good" a
without selecting the "bad" a
(using jQuery). I've tried .foo ul:not(.children) li a
but that doesn't work (obviously). Would it be possible to achieve in a one-liner?
Upvotes: 0
Views: 53
Reputation: 2052
in this particular scenario that you gave . it can be done by one lineras follows
$(a ,'.foo').first();
I hope it helps. If it does not work, do let me know and I'll delete my answer. thanks.
Upvotes: 0
Reputation: 532
Do this, it's one of the ways...
var good= $("a[href='link.bar']")
...
http://api.jquery.com/attribute-equals-selector/
Upvotes: 0