I have a html like:
<table id="message">
<tr class="clsaa1">
<td>
<div class="class3">
<table class="sub_1">
----------------------
----------------------
</table>
<div>
</td>
</tr>
<tr class="clsaa2">
<td>
<div class="class3">
----------------------
----------------------
<div>
</td>
</tr>
</table>
I need to remove all class
attributes inside #message
.
I have tried
$('#message').siblings().removeAttr('class');
and
$('#message').children().removeAttr('class');
But this is not working.
A simple and elegant solution would be:
$(".class").removeClass("class");`
Instead of removeAttr('class')
you can use removeClass("classname")
If you want to remove all the class values from its children, then do like
$('#message').find("*").prop("class","");
or even
$('#message').find('*') removeAttr('class');
Here is a fiddle.
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