prevent double click button link
by Akram kamal
HTML
<a href="#">This is my sample</a> |
<a href="#">This is my sample</a> |
<a href="#">This is my sample</a> |
<a href="#">This is my sample</a> |
<a href="#">This is my sample</a>
<ul>
</ul>
JavaScript
$("a").click(function(e) {
e.preventDefault();
if (!$(this).data('isClicked')) {
// Do stuff
var link = $(this);
$("ul").empty();
$("ul").prepend('<li>Clicked : ' + $(this).index() + '</li>');
link.data('isClicked', true);
setTimeout(function() {
link.removeData('isClicked')
}, 3000);
} else {
$("ul").empty();
$("ul").prepend('<li>Please wait - ' + $(this).index() + '</li>');
}
});