I'm writing the code to change the Button element value when the click event is executing.
But Until it finishes it doesn't affect the button element value.
I attached the fiddle example which will give you a good idea of what I'm talking about.
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
alert('hi')
}
Even the button element innerHTML changed before alert, it doesn't affect the UI.
How can I accomplish, before the alert is executed I need to change the button text?
Thanks.
Closest to threading in JS is settimeout function, this is not ok to do but here is how would it look like if you use it
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
setTimeout(function(){
alert('hi')
},1000)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With