Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery - How to check if element has any of these classes
- <div id="test" class="a1 a2 a5"></div>
- $("#test").is(".a1,.a2,.a3,.a4,.a5")
- if($('#test').filter('.a1, .a2, .a3').length)
- {
- //magic happens
- }
- var test = $('#test');
- if(test.hasClass('a1') || test.hasClass('a2') || test.hasClass('a3') ...) {
- ...
- }
- if ( $("#test").hasClass("a1") or $("#test").hasClass("a2") ...) { }
- if ($("#test").hasClass("a1") || $("#test").hasClass("a2") || $("#test").hasClass("a3") || $("#test").hasClass("a4") || $("#test").hasClass("a5")) {
- // Do something
- }
Add Comment
Please, Sign In to add comment