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.
精彩评论