Nothere
Nothere

Reputation: 29

Adding two different classes to one function at a different time javascript

I have a JavaScript code and there is one function that I want to add two class to it , but if I add them in the same function line the other class don't work , and when I write each one in the same function but different lines the second class works only , all what I want here is add the first class and add the second class after like 5sec ? I don't know if there is any way to make it work but I hope there is .

this is when the first class only works :

function open() {
        en.addClass('op').addClass('bo-ac')
            .removeClass('cl');
    }  

this is when the second class only works :

function open() {
            en.addClass('op')
                .removeClass('cl');
        }  

 function open() {
         $('.bo').addClass('bo-ac')
    }

Upvotes: 0

Views: 130

Answers (1)

Vinu Prasad
Vinu Prasad

Reputation: 968

@Nothere. I'm not sure, but is this something you are looking for ?

function open() {
    en.addClass('op').removeClass('cl');
    setTimeout(function() {
       en.addClass('bo-ac')
    }, 0)
} 

Upvotes: 1

Related Questions