开发者

How to use jQuery's .not and :contains in case of multiple values?

$("table[id=" + tblName + "] tr").not(":contains('" + val + "')").hide();

This code will开发者_运维技巧 hide all TRs not containing "val".

I have "val1" and "val2" in my code. I wish to hide TRs not containing both "val1" and "val2"

How do I do that?

^>^ Thanks for your help.


Logically an AND exclusion:

$("table[id=" + tblName + "] tr").not(":contains('" + val1 + "'):contains('" + val2 + "')").hide()

Logically an OR exclusion:

$("table[id=" + tblName + "] tr").not(":contains('" + val + "')").not(":contains('" + val2 + "')").hide();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜