Reputation: 975
I am using :contains()
to find strings in a large page of text content, and all of the repeating blocks will contain strings unique to those blocks, such as a student ID. I want to combine :contains()
with :not(:contains())
.
The logic is as follows: If string contains 1234, but the word "absent" is not present, append award statement
My goal is to combine the two selectors for a contains-but-doesn't-contain effect.
Upvotes: 0
Views: 458
Reputation: 167172
You can use filter
here:
$(selector).contains("1234").filter(function () {
return $(this).not(":contains("absent")");
});
Or in simple way:
$('selector:contains(1234):not(:contains(absent))')
Upvotes: 2