Skip to content
Related Articles
Open in App
Not now

Related Articles

How to disable button element dynamically using JavaScript ?

Improve Article
Save Article
Like Article
  • Difficulty Level : Easy
  • Last Updated : 12 Jan, 2023
Improve Article
Save Article
Like Article

The Button disabled property in HTML DOM is used to set or return whether a Button element would be disabled or not. A disabled element is un-clickable and unusable. It contains a boolean value.

Syntax: It is used to set the button disabled property.

buttonObject.disabled = "value"

Example: In this example, we will disable a button using the disabled attribute.


<body style="text-align:center">
    <h1 style="color: green;">
        How to disable button element<br>
        dynamically using JavaScript?
    <!-- Assigning id to Button. -->
    <button id="GFG" onclick="Geeks()">
    <p id="sudo"></p>
        function Geeks() {
                .disabled = "true";
                .innerHTML = "Button is Disabled";


Disable button element dynamically

Disable button element dynamically

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!