Alon Shmiel
Alon Shmiel

Reputation: 7121

Find by both conditions (both conditions appear)

I have the next li-s:

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

I want to find by both conditions:

I tried the next thing:

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

}

but I got:

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)

I want to get only the items that contains both things:

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

I tried:

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

}

but it doesn't work.

any help appreciated!

Upvotes: 1

Views: 49

Answers (2)

Maverick
Maverick

Reputation: 478

Try this

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

Upvotes: 1

Abhishek Jain
Abhishek Jain

Reputation: 2607

Try this:

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

It makes it something like this in your case:

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

}

Upvotes: 3

Related Questions