HTML | DOM Image name Property
The Image name Property in HTML DOM is used for setting or returning the value of the name Attribute of an <image> element.
Syntax:
imageObject.name
Property Values:
- name: It specifies the name of the Image.
Return Value: It returns a string value which represents the name of the Image.
Example-1: This Example returns an Image name Property.
<html> <body> <center> <img src= id="image" alt="" width="250" height="205" name="geeks" class="alignnone size-medium wp-image-1092360" /> <br> <br> <button type="button" onclick="getHeight()"> Click </button> <h4 id="text"></h4> </center> <script> function getHeight() { var imgObject = document.getElementById("image"); var output = document.getElementById("text"); output.innerHTML = "The name of the image is : " + imgObject.name; } </script> </body> </html> |
Before Clicking On Button:

After Clicking On Button:

Example-2: This Example sets the Image name Property.
<html> <body> <center> <img src= id="image" alt="" width="250" height="205" name="geeks" class="alignnone size-medium wp-image-1092360" /> <br> <br> <button type="button" onclick="getHeight()"> Click </button> <h4 id="text"></h4> </center> <script> function getHeight() { var imgObject = document.getElementById( "image").name = "Hello Geeks"; var output = document.getElementById( "text").innerHTML = "The name of the image was changed to " + imgObject; } </script> </body> </html> |
Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browsers supported by DOM Image name Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- HTML | DOM image naturalWidth property
- HTML | DOM Input Image name Property
- HTML | DOM Input Image alt Property
- HTML | DOM image naturalHeight property
- HTML | DOM Image complete Property
- HTML | DOM Input Image src Property
- HTML | DOM Input Image value Property
- HTML | DOM Input Image width Property
- HTML | DOM Input Image form Property
- HTML | DOM Input image autofocus Property
- HTML | DOM Input Image disabled Property
- HTML | DOM Input Image formEnctype Property
- HTML | DOM Input Image type Property
- HTML | DOM Input Image formTarget Property
- HTML | DOM input image height Property
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.



