按两个条件查找(两个条件都出现)

时间:2013-08-20 12:28:03

标签: jquery

我有下一个li-s:

your ad was Approved
your name was Approved
your ad was Deleted

我希望通过两个条件找到

我尝试了下一件事:

$("#notification-list").find(
"li:contains('was Approved'), li:not(:contains('your ad'))).each(function () {

}

但我得到了:

your ad was Approved (I got it cause 'your ad' is found here and 'was Approved')
your name was Approved (I got it cause 'was Approved' is found)
your ad was Deleted (I got it cause 'your ad' is found)

我想只获得包含这两件事的项目:

your ad was Approved (I got it cause 'your ad' is found here and 'was Approved')

我试过了:

$("#notification-list").find(
"li:contains('was Approved') and li:not(:contains('your ad'))).each(function () {

}

但它不起作用。

任何帮助表示赞赏!

2 个答案:

答案 0 :(得分:3)

试试这个:

$('li:contains("was Approved"):contains("your ad")')

在你的情况下它会像这样:

$("#notification-list").find(
    "li:contains('was Approved'):contains('your ad')).each(function () {

}

答案 1 :(得分:1)

试试这个

$("#notification-list li:contains('was Approved')").not(":contains('your ad')")