Skip to content

Instantly share code, notes, and snippets.

@akwiatkowski
Last active December 21, 2015 07:09
Show Gist options
  • Save akwiatkowski/6269174 to your computer and use it in GitHub Desktop.
Save akwiatkowski/6269174 to your computer and use it in GitHub Desktop.
Disable doubled clicks (js)
function do_nothing() {
return false;
}
// http://stackoverflow.com/questions/1681679/disabling-links-to-stop-double-clicks-in-jquery
// prevent a second click for 10 seconds. :)
$('.one_click').live('click', function(e) {
$(e.target).attr("disabled", "disabled");
$(e.target).click(do_nothing);
setTimeout(function(){
$(e.target).unbind('click', do_nothing);
$(e.target).removeAttr("disabled");
}, 10000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment