javascript - How To Call A Function After 'X' seconds Of onmousedown event -


i want call function after user hold button 'x' seconds. please help.

call settimeout() perform action after 3000 milliseconds, storing identifier settimeout() variable scoped above function. on element's mouseup(), clear timeout if exists via cleartimeout().

var divmousedown; $('#div-id').mousedown(function() { divmousedown = settimeout(function() {  // timeout action... }, 3000); }); $('#div-id').mouseup(function() { if (divmousedown) {  cleartimeout(divmousedown); } }); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -