For example, a click event can only be clicked once in two seconds.
var ms = 1000 * 2 ; var lastClick = Date.now()- ms; $( " a,div,p,li " ).click(function(){ if (Date.now()-lastClick >= ms) { lastClick = Date.now(); // Related operation } });
Date.Now() is the millisecond value of the returned timestamp