Open In App

HTML | DOM Input Image type Property

Last Updated : 14 Sep, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The Input Image type Property in HTML DOM is used to returning the which type of form element an image field is. 

Syntax: 

ImageObject.type 

Return Value: It returns a string value which represents the type of form element the Image field is. Below Example returns the Image Type Property.

Example: 

HTML
<!DOCTYPE html>
<html>
<head>
    <title>
        HTML DOM Input Image type Property
    </title>
</head>
<body style="text-align:center;">
    <h1 style="color:green;"> 
        GeeksForGeeks 
    </h1>
    <h2>DOM Input Image Type Property</h2>
    <button onclick="my_geek()">
        <input id="myImage"
               value="myGeeks"
               type="image"
               src=
"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png"
               alt="Submit" 
               formaction="#" 
               formtarget="#" 
               formenctype="text/plain" 
               width="48"
               height="48">
    </button>
    <h2 id="Geek_h" 
        style="color:green;"> 
    </h2>
    <script>
        function my_geek() {

            // Return the Input Image type Property
            var txt = document.getElementById(
                "myImage").type;
            document.getElementById(
                "Geek_h").innerHTML = txt;
        }
    </script>
</body>
</html>

Output: 

Before Clicking On Button:

  

After Clicking On Button:

  

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

  • Google Chrome
  • Edge 12+
  • Firefox
  • Apple Safari
  • Opera

Next Article
Article Tags :

Similar Reads