Document:all 属性

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

Document 接口的 all 只读属性会返回以文档节点为根的 HTMLAllCollection 集合。

与其使用 document.all 来按文档顺序返回包含所有文档元素的 HTMLAllCollection,不如使用 Document.querySelectorAll 按文档顺序返回包含所有文档元素的 NodeList

js
const allElements = document.querySelectorAll("*");

HTMLAllCollection,其中包含文档中的所有元素。

规范

Specification
HTML
# dom-document-all

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
all
Deprecated

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Deprecated. Not for use in new websites.
Has more compatibility info.