简体   繁体   English

单击添加课程,然后延迟删除课程(超时功能)

[英]Add class on click and then remove class on delay (timeout function)

I'm using jimdo but i have a head area where i be able to change all codes and everything works fine but this cool timeout feature. 我正在使用jimdo,但是我有一个头部区域,可以更改所有代码,并且一切正常,但是此超时功能很酷。 Any help would be great! 任何帮助将是巨大的!

This is my code which adds a class to an animated svg image which status is display:none. 这是我的代码,将一个类添加到状态为display:none的动画svg图像中。 With a click on a download button the svg image changes to display:block and runs 3 times and fades out after 3 second. 单击下载按钮,svg图像将更改为display:block并运行3次,并在3秒后消失。 So far so good. 到现在为止还挺好。 What i want is that the added class "s-dwlnd" will be removed after the svg fades out. 我想要的是在svg淡出后删除添加的类“ s-dwlnd”。 Exactly after 3 seconds to be correct :) ... Is there a way to do this? 恰好在3秒钟后才是正确的:) ...有没有办法做到这一点? To add a working timeout function to my existing code? 要向我的现有代码添加工作超时功能? Not all codes working with Jimdo :( 并非所有与Jimdo合作的代码:(

$( document ).ready(function() {
$( ".dwlnd-trg" ).click(function() {
    $( ".dwlnd" ).addClass( "s-dwlnd" );
});});

Yes, something like this should work: 是的,这样的事情应该起作用:

$( document ).ready(function() {
    $( ".dwlnd-trg" ).click(function() {
        $( ".dwlnd" ).addClass( "s-dwlnd" );

        setTimeout(function() {
            $(".dwlnd").removeClass("s-dwlnd");
        }, 3000); // Delay of 3 seconds
    });
});

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

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