Map name attribute

Definition and Usage

name Sets or returns the name of the image map's name attribute value.

name specifies the name of the image map.

The name attribute with <img> of usemap attribute Associated and create a relationship between the image and the map.

Note:When setting the name attribute, you should also set the <img> usemap attribute - if not set, the relationship between the image and the map will no longer exist (the clickable area will no longer be clickable).

Note:In HTML5,<map> The id attribute of the element must be name attribute Have the same value (and cannot be null or empty).

Example

Example 1

Get the name of the image map:

var x = document.getElementById("planetmap").name;

Try it yourself

Example 2

Change the name of the image map:

document.getElementById("planetmap").name = "newMapName";

Try it yourself

Syntax

Return name attribute:

anchorObject.name

set name attribute:

anchorObject.name = name

属性值

描述
name 规定图像映射的名称。

技术细节

返回值: 字符串值,表示图像映射的名称。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持

相关页面

HTML 参考手册:HTML <map> name অ্যাট্রিবিউট