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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -