I have a button (lets call it Toggler) that changes the disabled
property of another button then displays an alert()
message.
In Internet Explorer 11, when one clicks on Toggler, the button visually becomes disabled when the alert message displays.
However, in Chrome (54.0.2840.99), when one clicks on Toggler, the button does NOT visually become disabled when the alert message displays. Only after closing the alert box does the button become disabled.
How would I make both browsers (and Safari, Edge, etc - company computer so I don't have them) have the button appear disabled when the alert message pops up?
Barebones code to demonstrate
var btn;
var enabled = true;
function toggle() {
if (enabled) {
disableBtn(btn);
alert("Now Disabled");
} else {
enableBtn(btn);
alert("Now Enabled");
}
enabled = !enabled
}
function disableBtn(element) {
element.disabled = true;
}
function enableBtn(element) {
element.disabled = false;
}
window.onload = function() {
btn = document.getElementById("btn");
}
<button onclick="toggle();">Button to toggle things</button>
<br />
<br />
<button id="btn">Button that shows if enabled or not</button>