Check if a button “hasn't” been clicked within a certain amount of time (jQuery)
问题 Basically: You click a button and it runs function 1. If you don't click the button again within 1 second then function 2 runs. If you click the button within 1 second then it runs function 1 again. and so on and so forth... I can't figure out the logic to do this in Javascript. Is there even a way? Thanks in advanced! 回答1: from the top of my head (haven't tested this, but this seems most logic to me): var t = null; $("button").click(function() { console.log("this is function 1"); if (t !==