Skip to content

JavaScript change disabled attribute | Dynamically disabled it using JS code

  • by

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 will disable an input button.

<html>
<body>

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

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

    elem.disabled = true;
    
</script>
</html>

Output:

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

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading