隐藏所有缺少特定类的表行? [英] Hide all table rows that lack a particular class?

查看:105
本文介绍了隐藏所有缺少特定类的表行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery的toggleClass()方法来处理表行突出显示,而我想做的就是创建一个函数,该函数将隐藏所有没有 具有"highlight"类的表行已应用.

I am using a jQuery's toggleClass() method to handle table row highlighting and what I would like to do is create a function that will hide all table rows that do not have the "highlight" class applied.

表本身有一个ID(tblTest),每行也有一个ID.但是,在这种情况下,我不太关心ID的问题,而不是是否将"highlight"类应用于该行.基本上遍历每个表行,检查是否应用了"highlight:"类,如果未应用,则应用"hidden"类的最佳方法是什么.

The table itself has an ID (tblTest) and each row has an ID as well. However in this case I don't really care about ID's so much as whether or not the "highlight" class is applied to the row. What is the best approach for essentially walking through each table row, checking to see if the "highlight: class is applied and if it is NOT then apply the "hidden" class.

谢谢

推荐答案

使用jQuery隐藏它们:

To use jQuery to hide them:

$("#tblTest tr:not(.highlight)").hide();

要应用您的隐藏课程:

$("#tblTest tr:not(.highlight)").addClass("hidden");

您通常应该使用 jQuery效果隐藏内容.

You should generally favour the jQuery effects for hiding things however.

这篇关于隐藏所有缺少特定类的表行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆