此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

HTMLMapElement:name 属性

基线 广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

HTMLMapElementname 属性表示 <map> 元素的唯一名称。它的值可以与 <img> 元素的 useMap 属性一起使用,以引用 <map> 元素。

如果 <map> 元素设置了 id 属性,则 name 属性应该与其 id 属性相同。

一个没有空格的非空字符串。

示例

html
<map name="image-map">
  <area shape="circle" coords="15,15,5" />
</map>
js
const mapElement = document.getElementsByName("image-map")[0];
console.log(mapElement.name); // 输出:“image-map”

规范

规范
HTML
# dom-map-name

浏览器兼容性

参见