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

View in English Always switch to English

Document:all 属性

Deprecated

Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.

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

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

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

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

规范

规范
HTML
# dom-document-all

浏览器兼容性