JavaScript change disabled attribute | Dynamically disabled it using JS code

Just set the disabled property to false in JavaScript, it will change the disabled attribute in HTML. If you set disabled property true then HTML elements will disable.

document.getElementById("myId").disabled = false;

JavaScript change disabled attribute value example

HTML example code, it will disable a input button.


    <input id="dummy" type="button"  value="Submit" />

    var elem = document.getElementById('dummy');

    elem.disabled = true;


JavaScript change disabled attribute

Do comment if you have any doubts and suggestions on this topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.