HTML | DOM Input Image disabled Property

The HTML DOM Input Image disabled Property is used to set or return the boolean value that represents an image field should be disabled or not. By default, the disabled elements are displayed in gray and are unusable and unclickable.

Syntax:

  • It returns the disabled property.
    imageObject.disabled
  • It is used to set the disabled property.
    imageObject.disabled = true|false

Property values: This property accepts two parameter which are mentioned above and described below:



  • true: It specifies the image field is disabled.
  • false: It specifies the image field is not disabled.

Return value: It returns a boolean value i.e. true if the image field is disabled or false if the image field is not disabled.

Example 1: This example returns the value of disabled proper

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML DOM Input Image Disabled property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
      GeeksforGeeks 
    </h1
    <h4>
      DOM Input Image Disabled Property
    </h4>
    <input id="myImage" formEnctype="application/x-www-form-urlencoded" 
           type="image" formtarget="#" src=
           alt="Submit" width="48" height="48" formMethod="post"
           disabled>
    <br>
    <br>
    <button onclick="my_geek()">Submit </button>
  
    <h2 id="Geek_h" style="color:green;"></h2>
    <script>
        function my_geek() {
  
            // Return target, alt and height. 
            var txt = document.getElementById(
                "myImage").disabled;
            document.getElementById(
                "Geek_h").innerHTML = txt;
        }
    </script>
</body>
  
</html>

chevron_right


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

Example 2: This Example sets the value of the Disabled Property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML DOM Input Image Disabled property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
      GeeksforGeeks 
    </h1>
  
    <h4>
      DOM Input Image Disabled Property
    </h4>
    <input id="myImage" formEnctype="application/x-www-form-urlencoded" 
           type="image" formtarget="#" src=
           alt="Submit" width="48" height="48" formMethod="post"
           disabled>
    <br>
    <br>
    <button onclick="my_geek()">Submit </button>
  
    <h2 id="Geek_h" style="color:green;"></h2>
    <script>
        function my_geek() {
  
            // set Disabled Property. 
            var txt = document.getElementById(
                "myImage").disabled = false;
            document.getElementById(
                "Geek_h").innerHTML = txt;
        }
    </script>
</body>
  
</html>

chevron_right


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

Supported Browsers: The browsers supported by HTML DOM Input Image disabled Property are listed below:

  • Google Chrome 10.0
  • Firefox 4.0
  • Opera 11.0
  • Safari 5.1


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.