How to check the existence of the class in this jQuery case? [closed]

1

How can I check if the class exists in a variável of jQuery?

jQuery(function($) {

    // Captura o atributo para manipulá-lo
    var atributo = jQuery(this).parent('.servico').children('.servicos_the_content');

I tried this but it did not work:

if($(atributo)).hasClass('active'){

     // faz alguma coisa

}
    
asked by anonymous 16.08.2015 / 23:09

1 answer

2

Notice that you have an error in logic and parentesis:

if($(atributo)).hasClass('active'){

should be

if(atributo.hasClass('active')){

In this case atributo is already a jQuery object.

    
17.08.2015 / 00:54