开发者

Remove row class from table -Jquery

开发者 https://www.devze.com 2023-02-13 22:54 出处:网络
I have a table .Table id is resultTable.Some of the rows in the table have a clas开发者_如何学运维s.

I have a table .Table id is resultTable. Some of the rows in the table have a clas开发者_如何学运维s.

How can i remove those classes from that table.

I am using the code given below to add the class

     $('#resultTable tr').click(function (event) {
       $(this).addClass("test");
       });

TO remove the class test from the entire table , i tried the code given below

   $('#resultTable').removeClass("test");

But its not working.Any ideas?


You forgot a tr

$('#resultTable tr').removeClass("test");


To remove all classes from all table rows of the resultTable:

$('#resultTable tr').removeAttr('class');

To remove just the class of 'test':

$('#resultTable tr.test').removeClass('test');


$('#resultTable').find('.test').each(function(){
  $(this).removeClass("test");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消