Whoops! Don't forget you...">

Selecting elements with multiple classes in jQuery

I have message elements like this ...

<span class="error message">Whoops!  Don't forget your name.</span>

A...

<span class="success message">All done!  Thank you very much.</span>

You will notice that two classes apply to one element span. This is a valid markup. How to select items with two classes?

Note. I do not want all elements to have a class attribute containing a "message". I need elements that have both an “error” and a “message” (and nothing more).

+5
source share
1 answer
$('.error.message')

must do it.

+14
source

All Articles