javascript - How to calculate interval time when same button clicked twice in java script or jquery -



javascript - How to calculate interval time when same button clicked twice in java script or jquery -

there 1 button java script of j query , first time press button, after seconds 1 time again press same button. how calculate interval time between 2 presses of same button. please can help.

code tried: code downwards , ip, how can calculate same button preesing

var starttime, endtime; $("#bu").on('mousedown', function () { starttime = new date().gettime(); }); $("#bu").on('mouseup', function () { endtime = new date().gettime(); longpress = (endtime - starttime < 500) ? false : true; });

try this

class="snippet-code-js lang-js prettyprint-override">var starttime; $("#bu").on('click', function() { if(starttime) { alert( "time difference: " + (new date().gettime() - starttime) ); starttime = undefined; } else { starttime = new date().gettime(); } }); class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input type="button" id="bu" value="click me" />

javascript jquery dom javascript-events

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -