Jquery Delay After Click

前端 未结 7 1991
無奈伤痛
無奈伤痛 2020-12-29 08:58

I\'m creating a web app...

i got a kind of game, my idea is when the user completes each level appears a dialog box with some information, it is fine.

Now my

7条回答
  •  被撕碎了的回忆
    2020-12-29 09:15

    Use setTimeout() with a delay of 5000 ms.

    $("button").click(
        function() {
            console.log("clicked...waiting...");
    
            setTimeout(
                function() {
                    alert("Called after delay.");
                },
                5000);
        });
    
    

    Just out of curiosity, why would you want to wait 5 seconds before prompting the user in response to an action? That's a long time; long enough for them to have clicked on a bunch of other things (if nothing else).

提交回复
热议问题