Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the opposite of jQuerys "hasClass"?

Currently I have some code that reads

    if ( $(this).hasClass('.someclass') ) 
     { } 
     else {
     //Do Stuff here.
     }

I know this isn't exactly kosher, but it works.

What's the proper way to go about this? How do I check for the abscence of a class?

like image 504
Luke The Obscure Avatar asked Nov 28 '22 19:11

Luke The Obscure


1 Answers

Invert the test:

if (!$(this).hasClass('someclass')) 

I think also that the . should not be in front of the class name. See the documentation.

like image 174
Mark Byers Avatar answered Dec 05 '22 15:12

Mark Byers