开发者

jQuery: How can you test for the *absence* of a class?

Given that this is the corr开发者_开发百科ect way to see if 'this' has class 'selected':

if ($(this).hasClass('selected')) {
   // logic goes here
}

What is the correct way to test for the absence of a class?

That is, how can I test if 'this' does not have class 'selected'?


if (!$(this).hasClass('selected')) {
    // logic goes here
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜