Big Carlos Big Carlos - 1 year ago 48
Javascript Question

javascript does not work

I'm trying to make this JavaScript code working but I'm new in this and it's so hard for me. I need help.



function myFunction(button) {
button.disabled = true;
button.innerHTML = "Waiting...";

setTimeout(function() {
button.innerHTML = "Thank you!";
button.disabled = false;
}, 2000);
});

<a target="_blank" href="#"><button type="button" id="btn" onclick="myFunction(button)" class="btn btn-default"> Try </button></a>





How can I fix it?

Answer Source

Try this

onclick="myFunction(this)" 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download