简体   繁体   English

在不同的时间向一个 function 添加两个不同的类 javascript

[英]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 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将第二个 class 排成一行,我想要的只是添加第一个 class 并在 5 秒后添加第二个 class? 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:这是第一个 class 仅适用的时间:

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

this is when the second class only works:这是第二个 class 仅起作用的时候:

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

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

@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)
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM