Last active
August 29, 2015 14:13
-
-
Save olvap/4bb6a9050e2d4449aab5 to your computer and use it in GitHub Desktop.
disable button and re able again after 10 secs.
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
$('a').click(function () { | |
// button is the clicked button | |
var button = $(this); | |
if(button.attr('href') !== "#") { | |
var url = button.attr('href'); | |
} | |
// add the spining image | |
button.html("<i class='icon-spinner icon-spin icon-large'></i>"); | |
// set the href to '#' to avoid reclicking before 1 milisec | |
setTimeout(function() { | |
button.attr('href', '#') | |
},1); | |
// if for some reason the page wasn't redirectec after 10 seconds | |
// remove the spining image and return the href attribute to original. | |
setTimeout(function() { | |
button.html(""); | |
button.attr('href', url); | |
}, 10000 ); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment