How do you temporarily disable all events in javascript? We want to make them disabled, so that some events don't run until after 700 miliseconds after we click something.
If you're trying to temporarily disable all clicks, then a simple way to do that without changing any of the rest of your page or code is to put up a transparent div absolutely positioned over the whole page that intercepts and stops propagation of all click events. Then, use a setTimeout() to remove that transparent div at whatever time interval you want.
Put the blockDiv in your page HTML so it's already there.
In your HMTL:
<body>
<div id="blockDiv"></div>
... other page HTML here
</body>
Then, have this CSS in the page:
#blockDiv {
position: absolute;
left: 0;
right: 0;
height: 100%;
width: 100%;
z-index: 999;
}
And, this javacript:
$("#blockDiv").click(function(e) {
// stop propagation and prevent default by returning false
return false;
});
setTimeout(function() {
$("#blockDiv").remove();
}, 700);
setTimeout
is what you want.
The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.
it takes two parameters:
1) the function or code to call and
2) the number of milliseconds to wait before executing the code/function.
setTimeout(function(){
//do your stuff
},700);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With