这篇翻译不完整。请帮忙从英语翻译这篇文章

Element.getAttributeNames() 返回一个Array,该数组包含指定元素(Element)的所有属性名称,如果该元素不包含任何属性,则返回一个空数组。

将 getAttributeNames()getAttribute() 组合使用, 是一种有效替代 Element.attributes 的使用方法.

Syntax

let attributeNames = element.getAttributeNames();

Example

// Iterate over element's attributes
for(let name of element.getAttributeNames())
{
	let value = element.getAttribute(name);
	console.log(name, value);
}

Specifications

Specification Status Comment
DOM
Element.getAttributeNames
Living Standard Initial definition

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 61 45 (45) 未实现 48 9
Feature Android Webview Chrome for Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support 61 61 ? ? ? 48 ?

文档标签和贡献者

标签: 
此页面的贡献者: BLSM53
最后编辑者: BLSM53,