Map name Property
Example
Get the name of an image-map:
var x = document.getElementById("planetmap").name;
The result of x will be:
planetmap
Try it yourself »
Definition and Usage
The name property sets or returns the value of the name attribute of an image-map.
The name attribute specifies the name of an image-map.
The name attribute is associated with the <img>'s usemap attribute and creates a relationship between the image and the map.
Note: When setting the name property, you should also set the <img>'s usemap attribute - if not, the relationship between the image and the map will no longer exist (clickable areas will no longer be clickable).
Note: In HTML5, the id attribute of the <map> element must have the same value as the name attribute (and it cannot be null or empty).
Browser Support
The name property is supported in all major browsers.
Syntax
Return the name property:
mapObject.name
Set the name property:
mapObject.name=name
Property Values
Value | Description |
---|---|
name | Specifies the name of an image-map |
Technical Details
Return Value: | A String, representing the name of the image-map |
---|
More Examples
Example
Change the name of an image-map:
document.getElementById("planetmap").name = "newMapName";
Try it yourself »
Related Pages
HTML reference: HTML <map> name attribute
Map Object