TUTORIAL前端与浏览器FETCHED
HTML DOM attributes 属性
HTML DOM attributes 属性 元素对象 实例 获取元素属性的集合: [mycode3 type='javascript']document.getElementsByTagName('BUTTON')[0].attributes;[/mycode3] 尝试一下 » 定义和用法 attributes 属性返回指定节点属性的集合。 提示: 你可以使用 length 属..
更新于 2026/7/16
教程详情页默认 noindex。
HTML DOM attributes 属性
定义和用法
attributes 属性返回指定节点属性的集合。
提示: 你可以使用 length 属性确定属性的数量,然后你可以遍历所有的属性节点提取你想要的信息。
提示: 每个属性都是可用属性节点对象。
浏览器支持
![]()
![]()
![]()
![]()
![]()
所有主要浏览器都支持 attributes 属性
注意: 在 Internet Explorer 8 以及更早的版本中,attributes 属性会返回元素所有可能属性的集合。
语法
node.attributes
技术细节
| 返回值: | NamedNodeMap 对象, 表示属性的集合。 |
|---|---|
| DOM 版本 | Core Level 1 Node Object |
元素对象