Disable or Enable HTML Element with JavaScript


Hi. I needed to make the HTML elements enabled or disable. When I try with VanillaJS I wrote this code: VanillaJS Way JS Code function disableOrEnableBtn() { var isDisabled = document.getElementById("myBtn").disabled; if(isDisabled) { document.getElementById("myBtn").disabled = false; } else { document.getElementById("myBtn").disabled = true; } } HTML Code <button id="myBtn">Button</button> <button onclick="disableBtn();">Change Button Status</button> See VanillaJS Example […]