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
Post a Comment