Reputation: 1059
I have a list like that:
<div class="cloned"><a rel="test" href="" title=""></a></div>
<div><a rel="test" href="" title=""></a></div>
<div><a rel="test" href="" title=""></a></div>
<div><a rel="test" href="" title=""></a></div>
<div class="cloned"><a rel="test" href="" title=""></a></div>
I would like to use jQuery to select all <a>
with rel=test
excluding all <a>
that are inside div class cloned. Something like that
$("div:not(.cloned) a[rel=test]")
Thank you
Upvotes: 0
Views: 1766
Reputation: 630607
Exactly what you have will work:
$("div:not(.cloned) a[rel=test]")
You can test it here, make sure you're inside a document.ready
handler if you're having issues, like this:
$(function() {
$("div:not(.cloned) a[rel=test]").css('color', 'red');
});
Upvotes: 7