xxx

Select each item that is not inside another item.

<img src="xxx" alt="xxx" title="xxx"> <div class="buttons"> <a href="xxx"><img src="xxx" alt="xxx" title="xxx"></a> </div> 

I need to write a jQuery selector that will select ONLY images with header attributes that are INDEPENDENT..buttons div. I know that to select images with header attributes I need to use something like this:

 $("img[title]") 

I know there is something like: not () selector in jQuery, but I cannot find a way to combine them to achieve this exact result.

+4
source share
1 answer

You can get a result set, then filter it using .not() , for example:

 $("img[title]").not(".buttons img") 

Or filter in the same selector using :not() (but this is probably a bit slower in older browsers), for example:

 $("img[title]:not(.buttons img)") 
+21
source

All Articles