HTML | DOM Map name Property
The Map name property in HTML DOM is used to set or return the value of the name attribute of a map element. This attribute specifies the name of the mapping image. This attribute is associated with <img> usemap attribute. It creates a relationship between the <image> and <map> element.
Syntax:
- It returns the name property.
mapObject.name
- It is used to set the name property.
mapObject.name = name
Property Values:
- name: It holds the name of the an image-map.
Return Value: It returns a string value which represents the name of the map element.
Example:
<!DOCTYPE html> <html> <head> <title> HTML DOM Map name Property </title> </head> <body> <h2> GeeksForGeeks </h2> <h3> HTML DOM Map name Property </h3> <h4>Click the button</h4> <map id = "Geeks" name = "Geeks"> <area = "rect" coords = "0, 0, 110, 100" alt = "Geeks" href = <area shape = "rect" coords = "110, 0, 190, 100" alt = "For" href = <area shape = "rect" coords = "190, 0, 300, 100" alt = "GEEKS" href = </map> <img src = width = "300" height = "100" alt="GFG" usemap = "#Geeks"> <br><br> <button onclick = "GFG()"> Click Here! </button> <p id = "GEEK!"></p> <script> function GFG() { var x = document.getElementById("Geeks").name; document.getElementById("GEEK!").innerHTML = x; } </script> </body> </html> |
Output:
- Before Clicking the Button:

- After Clicking the Button:

Example 2:
<!DOCTYPE html> <html> <head> <title> HTML DOM Map name Property </title> </head> <body> <h2> GeeksForGeeks </h2> <h3> HTML DOM Map name Property </h3> <h4>Click the button</h4> <map id = "Geeks" name = "Geeks"> <area = "rect" coords = "0, 0, 110, 100" alt = "Geeks" href = <area shape = "rect" coords = "110, 0, 190, 100" alt = "For" href = <area shape = "rect" coords = "190, 0, 300, 100" alt = "GEEKS" href = </map> <img src = width = "300" height = "100" alt="GFG" usemap = "#Geeks"> <br><br> <button onclick = "GFG()"> Click Here! </button> <p id = "GEEK!"></p> <script> function GFG() { var x = document.getElementById("Geeks").name = "Hello Geeks"; document.getElementById("GEEK!").innerHTML = "The name was changed to " + x; } </script> </body> </html> |
Output:
- Before Clicking the Button:

- After Clicking the Button:

Supported Browsers: The browsers supported by HTML DOM Map name property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
Recommended Posts:
- HTML | DOM Bdo dir Property
- HTML | DOM dir Property
- HTML | DOM li value Property
- HTML | DOM name Property
- HTML | DOM specified Property
- HTML | DOM URL Property
- HTML | DOM value Property
- HTML | DOM id Property
- HTML | DOM lastModified Property
- HTML | DOM fullscreenElement Property
- HTML | DOM IFrame src Property
- HTML | DOM Button value Property
- HTML | DOM Ol start Property
- HTML | DOM IFrame name Property
- HTML | DOM offsetParent 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.


