Jquery Select Element with Not Empty Attribute

If you need to get elements which an attribute is not empty, you need to use the following code below.

This code returns div elements which have id
[js]
$(‘div[id]’);
Output: Object[div#page, div#header, div#logo]

$(‘[attrName]’);
[/js]

This code returns div elements which have no id
[js]
$(‘div:not([id])’);

$(‘:not([attrName])’)
[/js]

This code returns elements which have no class
[js]
$(‘:not([class])’);
[/js]

With this way you can select div, span, p, label etc. which has class, id, name or any attribute and which does not have class, id, name or any attribute.