开发者

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

开发者 https://www.devze.com 2023-03-24 01:50 出处:网络
$(\"table[id=\" + tblName + \"] tr\").not(\":contains(\'\" + val + \"\')\").hide(); This code will开发者_运维技巧 hide all TRs not containing \"val\".
$("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

精彩评论

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

关注公众号