开发者

What is the opposite of jQuerys "hasClass"?

开发者 https://www.devze.com 2023-01-23 04:29 出处:网络
Currently I have some code that reads 开发者_如何学运维if ( $(this).hasClass(\'.someclass\') )

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?


Invert the test:

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消