Front.
One day on a whim, 1 minutes repeatedly clicked on the blog home page Refresh blog list refresh button. Sure enough, IP was disabled at the time. Later, restart your router and retrieve the IP to access the blog's home page. Would it be better to set a limit of time (for example, 1 seconds) to prevent the button from being repeatedly clicked?
Idea of a
The most direct idea may be to click the button, the button's event binding function to bind, 1s after the binding function
<button id= "btn" >0</button>
<script>
btn.onclick = function Add () {
btn.innerhtml = Number (btn.innerhtml) + 1;
Btn.onclick = null;
Cleartimeout (timer);
var timer = settimeout (function () {
Btn.onclick = add;
},1000);
}
</script>
Idea Two
Another idea is to get and record time, and when clicked again, the time interval is greater than 1s.
<button id= "btn" >0</button>
<script>
Btn.onclick = (function () {
var last = Date.now ();
return function () {
var now = Date.now ();
if ((now-last) >1000) {
btn.innerhtml= number (btn.innerhtml) + 1;
}
last = Now;
}
) ();
</script>
The above about JavaScript in the limited time to prevent the button repeatedly click on the idea is small set to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.