Area alt attribute
Definition and usage
Alt
Attribute sets or returns the area Alt attribute The value.
If the image cannot be displayed, the alt attribute specifies the alternative text for the area.
Example
Example 1
Get the alternative text for a specific area in the image map:
var x = document.getElementById("venus").alt;
Example 2
Change the alternative text for a specific area in the image map:
document.getElementById("venus").alt = "The planet Venus";
Syntax
Return alt attribute:
areaObject.alt
Set alt attribute:
areaObject.alt = text
属性值
值 | 描述 |
---|---|
text | 该区域的替代文本。 |
技术细节
返回值: | 字符串值,表示该区域的替代文本。 |
---|
浏览器支持
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |
相关页面
HTML 参考手册:HTML <area> alt 属性