I need to use jQuery to search for all DIV tags that have no attributes, and apply a class to each. Here is an example HTML:
<div id="sidebar"> <div>Some text goes here</div> <div class="something">something goes here</div> <div>Another div with no attributes.</div> </div>
So, I need to take this and turn it into:
<div id="sidebar"> <div class="myClass">Some text goes here</div> <div class="something">something goes here</div> <div class="myClass">Another div with no attributes.</div> </div>
How do you find div elements that have no attributes through jQuery? Thanks.
source share