Last active
December 21, 2015 07:09
-
-
Save akwiatkowski/6269174 to your computer and use it in GitHub Desktop.
Disable doubled clicks (js)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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