Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find child elements by missing attribute with jQuery

Finding elements by attribute in jQuery is simple:

$(parentElement).find('[attribute]');

How do you find elements, that don't have a certain attribute?

like image 995
Jbartmann Avatar asked Apr 15 '14 07:04

Jbartmann


2 Answers

That's why the :not() is made for.

Try,

$(parentElement).find(':not([attribute])');
like image 73
Rajaprabhu Aravindasamy Avatar answered Oct 13 '22 02:10

Rajaprabhu Aravindasamy


You can use :not although filter is most likely faster:

$(parentElement).filter(function() {
    return !$(this).attr('attribute');
});
like image 26
Rory McCrossan Avatar answered Oct 13 '22 03:10

Rory McCrossan