开发者

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?


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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜