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
Read More:
- WPF: How to implement Text Stroke
- [Solved] Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory
- @requestbody: How to Use or Not Use
- How to use HPQC on Chrome browser
- [Solved] Vue Element Date plug-in reports an error in form validation
- How to Use DOM to operate CSS
- JS: How to Solve split, join, toString Use error
- How to use Runtime.getRuntime().Exec()
- The date selector Report Null Error in element is cleared
- Vue2.0: How to Use vue3 api to encapsulate Axios
- [Solved] el-date-picker Error: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders.
- Javascript SecurityError: Failed to read the’localStorage’ property from’Window’: Access is denied for this document.
- JavaScript determines whether it’s morning or afternoon or evening
- JavaScript Common Errors List (Reasons & Solutions)
- Uncaught Error: Unrecognized datatype for attribute “news.news_date“
- [Solved] Vite Error: Failed to load module script: Expected a JavaScript module script but the server…
- Javascript: Simple package localStorge operation
- [Solved] Front end error: Unknown custom element
- [Solved] Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs extension
- Front end initialization Vue element admin error [How to Solve]