I want to select an/all element which doesn't have any attribute associated with it.is there any way to select particular element without considering what attributes other paragraphs tags contain?
For example:
<p class="a" id="para1">This is paragraph 1</p>
<p id="para2" class="a b c d e f" >This is paragraph 2</p>
......
......
<p>This is paragraph 3</p> <!-- select this p without attribute -->
<div>
<p class="inside-div" id="para5">This is paragraph</p>
</div> <!-- select this div without attribute-->
You can use attributes collection of html element to find out if there is any attribute.
Demo
ps = $('p').filter(function(){
return this.attributes.length == 0;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With