Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
146
rated 0 times [  150] [ 4]  / answers: 1 / hits: 16617  / 14 Years ago, tue, august 10, 2010, 12:00:00

I am trying to select elements of a (certain class || another class) with the same selector. How can I go about doing that?



Currently, I have:



$(.class1 .class2).each(function(idx, el) {... });


however, that only selects elements that match both classes, not one or the other.



How can I select elements that match one or both of the classes, with the same selector?


More From » jquery

 Answers
15

Try this



$(.class1,.class2)


http://api.jquery.com/multiple-selector/


[#95975] Friday, August 6, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jamaal

Total Points: 515
Total Questions: 102
Total Answers: 107

Location: France
Member since Thu, May 6, 2021
3 Years ago
;