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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -