How to remove class from all child elements

Shijin TR picture Shijin TR · Mar 26, 2014 · Viewed 31.3k times · Source

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.

Answer

Adi picture Adi · Dec 30, 2015

the simple and elegant solution would be just:

$(".class").removeClass("class");