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