Hopefully I can explain this better than I can Google it!
I have a Jquery rule that detects a certain word then applies a class to that elements parent container which works as hoped.
Instead of simply duplicating this rule for additional words I would like to just include them in the rule effectively as an “OR”.
This is what I have that works:-
$(".container:contains(Word1)").each(function(){
$(this).closest("#containerParent").addClass("newClass");
});
This is the none-working attempt:-
$(".container:contains(Word1)"|".container:contains(Word2)").each(function(){
$(this).closest("#containerParent").addClass("newClass");
});
As an alternative I could make it a function of course, but I would like to do it “properly” or in a cleaner way.
What do you think?
Try this way: