How can I get the elements without a particular attribute using jQuery?
jquery
Solution
First thing that comes to my mind (maybe sub optimal) :
$('p').filter(function(){
return !$(this).attr('attr_all');
});
However `p:not([attr_all])` should work, so I think something else is going on in your code.
Problem
I know how to get elements with a particular attribute: ``` $("#para [attr_all]") ``` But how can I get the elements WITHOUT a particular attribute? I tried: ``` $("#para :not([attr_all])") ``` but it didn't work. What is the correct way to do this? Let me give an example: HTML: ``` <div id="para"> <input name="fname" optional="1"> <input name="lname"> <input name="email"> </div> ``` jQuery: ``` $("#para [optional]") // give me the fname element $("#para :not([optional])") // give me the fname, lname, email (fname should not appear here) ```