Delaying click event

后端 未结 4 1126
滥情空心
滥情空心 2021-02-20 11:54

I\'m wondering whether there\'s a simple way to delay the click event from being processed for a specified period of time. For example we could have

$(\'#someEle         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-02-20 12:37

    window.setTimeout will execute any given function after a specified delay.

    You'd call it like this:

    $('yourElement').click(function (event) {
        setTimeout(function () { console.log('hi'); }, 1000);
    });
    

    But I have to wonder why you need to do this. What's the problem you're trying to solve? Usually delaying stuff doesn't really solve anything.

提交回复
热议问题