I want to disable this link for a few seconds.
<a href="#" data-role="button" data-theme="f" data-rel="popup" id="deshabilitar" type="button" data-icon="cloud-upload" data-iconshadow="true" onclick="deshabilitar()"></a>
so that it only allows you to click once. In the function I have this code but it doesn't do it to me and I don't see why. Thanks.
var button = $('#deshabilitar');
button.attr('disabled', 'disabled');
setTimeout(function() {
button.removeAttr('disabled');
},3000);
What you could do is give the binding the property
pointer-events
ofcss
with valuenone
byjavascript
and a few seconds later remove that property so that it is enabled again.Here is an example:
This would be the
HTML
:And this is him
javascript
:I've tried it and it works, I hope it works for you.
Maybe you didn't have the reference right, try with:
I think the problem is that you can't add the attribute
disabled
to a link. In this link (in English) you have information on the best way to disable itA link is not a form control so you can disable it to avoid the default behavior.
Try adding a state of enabled/disabled to the link and depending on the state of the link, you do the corresponding action.
Here an example:
What it does is simple, add a class called
deshabilitado
when element is clicked. This class changes the color and the cursor to give the impression that it is disabled. Then after the elapsed time the styles are eliminated and the link is enabled again.