pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/zh-CN/docs/Web/API/Element/getAttributeNames

zes="32x32" href="https://developer.mozilla.org/favicon.ico" />

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

View in English Always switch to English

Element.getAttributeNames()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2018年10月.

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

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

语法

let attributeNames = element.getAttributeNames();

例子

js
// 遍历 elements 的元素
for (let name of element.getAttributeNames()) {
  let value = element.getAttribute(name);
  console.log(name, value);
}

规范

Specification
DOM
# ref-for-dom-element-getattributenames①

浏览器兼容性

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy