从表中删除行类 -Jquery

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5154690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 18:39:16  来源:igfitidea点击:

Remove row class from table -Jquery

jqueryhtml

提问by Null Pointer

I have a table .Table id is resultTable. Some of the rows in the table have a class.

我有一个表。表 id 是 resultTable。表中的某些行有一个类。

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?

但它不起作用。任何想法?

回答by Andrea

You forgot a tr

你忘记了一个 tr

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

回答by David says reinstate Monica

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

要从 的所有表行中删除所有类resultTable

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

To remove just the classof 'test':

仅删除class“测试”:

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

回答by Alex

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