How to add a class to every second th element in every tr element?

<tbody> <tr> <th><th> <th><th> </tr> <tr> <th><th> <th><th> </tr> </tbody> $(".highlited tbody:nth-child(1) tr th:nth-child(2) ").addClass("hidden"); 

    1 answer 1

    The <th> tag is not closed, your code works fine and the second class adds a hidden class

     <table class="highlited"> <tbody> <tr> <th></th> <th class="hidden"></th> </tr> <tr> <th></th> <th class="hidden"></th> </tr> </tbody> </table>