views:

75

answers:

1

Given that this is the correct 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'?

+7  A: 
if (!$(this).hasClass('selected')) {
    // logic goes here
}
Venr
Brilliant! Problem solved in a single (key) stroke :-)
James Wiseman