views:

46

answers:

1

Hi there,

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

+7  A: 

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');​
});
Nick Craver