Maybe I wasn’t searching in the right way, but I couldn’t find anywhere that would specifically tell me how to select elements that do NOT have an attribute in jQuery. I founds lots of blogs that just repeated the jQuery site on how to find elements that do have an attribute (or one with a specific value) but not the opposite.
So here is the answer
<br /> <div id="parent"><br /> <div name="fred"></div><br /> <div name="jane"></div><br /> <div>pick me!</div><br /> <div name="rod"></div><br /> </div></p> <p>//the line below will return the div without a name attribute i.e. 'pick <div style="display: none"><a href='http://buyviagraonlineed.org/' title='generic viagra'>generic viagra</a></div> me!'<br /> $("#parent").children("div :not([name])");</p> <p>
Obvious I guess, but I couldn’t work this out before staring at the book for ages…. but then if I get no comments I’ll assume it was just me )