Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
156
rated 0 times [  161] [ 5]  / answers: 1 / hits: 18552  / 10 Years ago, wed, april 23, 2014, 12:00:00

I am finding all the divs in a document which contains inside a text: 'thetext' and i am changing this text:



$(div:contains('thetext'):not(:has(*))).each(function () {

$(this).text($(this).text() + anotherTextAddedBefore);

})


Is it possible to put inside contains multiple values?
I would like to find the divs whic contains: 'thetext', but also another values, for example: 'thetext1', 'thetext2',etc



I`d want to make it in one procedure and not in more: dont want to use as many procedures as texts i´d like to find.



Thanks!


More From » jquery

 Answers
19

You can use the multiple selector as a or condition like



$(div:not(:has(*))).filter(:contains('thetext'), :contains('thetext2')).each(..)

[#71329] Tuesday, April 22, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
collinisaaka

Total Points: 194
Total Questions: 105
Total Answers: 104

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;