1
Good this by mounting a custom css button. I need to keep it locked for 2 seconds after the first click, but it is not working. When I click I change the text to an icon, and after 2 seconds the text has to go back and the button has to be released for the click.
Someone knows what I’m doing wrong?
$(document).ready(function () {
$("button").click(function () {
$(this).html("<i class='material-icons animate-spin'>autorenew</i>");
// Desabilita o botao
$(this).disabled = true;
// Habilita novamente após dois segundos (2000) ms
setTimeout(function () {
toggleDisabled($(this));
}, 2000);
function toggleDisabled(elem) {
elem.disabled = !elem.disabled;
}
});
});
.bt {
transition: all .3s ease-out;
transition-property: all;
transition-duration: 0.3s;
transition-timing-function: ease-out;
border:0;
padding:10px;
width:200px;
height: 50px;
display: inline-block;
margin: 10px;
cursor: pointer;
border-radius: 4px;
background-color: #0091FF;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Material Icons (Google) -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<button class='bt' type='submit'>OK</button>
Exactly that. You’re in the wrong context of
this
.– Leandro Oriente
I put your idea together with Antonio’s and it worked, thank you
– Hugo Borges