jQuery包含选择器-多个文本项 [英] JQuery Contains Selector - Multiple Text Items

查看:105
本文介绍了jQuery包含选择器-多个文本项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JQuery的新手,也许还没有找到明显的东西,但是我该如何使用contains选择器过滤表,却要使用OR运算符查找多个字符串.换句话说,我希望包含红色"或黄色"的行被隐藏.

I am new to JQuery and maybe am missing the obvious, but how can I filter a table using the contains selector but have it look for multiple strings using an OR operator. In other words, I would like rows containing "Red" OR "Yellow" to be hidden.

到目前为止,我可以通过隐藏除给定日期之外的所有行来工作:

So far I have this which works by hiding all rows except the given date:

$(function()
{
    $('div#WebPartWPQ5 table.ms-summarycustombody tr:not(:contains("10/27/2009"))')
        .hide();
});

还有一个挑战,我真正想做的是编写一个隐藏的脚本,该脚本计算日期范围,然后删除包含不属于该范围的日期的表行.

As added challenge, what I am really trying to do is write a hidden script that calulates a date range and then removes table rows containing dates not falling into that range.

谢谢.

约翰

推荐答案

用逗号分隔不同的选择器字符串.

Separate the different selector strings with commas.

$('table tr.red, table tr.yellow').hide()

这篇关于jQuery包含选择器-多个文本项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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