Aessandro
Aessandro

Reputation: 5761

jQuery to check if element has no specific class applied

I would like to check if an element has not a specific class applied. Is this correct?

if($('#tabs_wrapper li').hasClass:not('enabled')){
$('.inner_tabs div').css('display', 'none');
 }

Upvotes: 1

Views: 213

Answers (2)

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123377

just an alternative

if ($('#tabs_wrapper li:not(".enabled")').length) {
   /* ... */
}

Upvotes: 1

Denys Séguret
Denys Séguret

Reputation: 382102

You may do this :

 if (!$('#tabs_wrapper li').is('.enabled')){
    $('.inner_tabs div').css('display', 'none');
 }

Reference

Upvotes: 1

Related Questions