Javascript document.all 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13663023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does document.all mean?
提问by user1170330
Possible Duplicate:
document.all vs. document.getElementById
I'm refactoring some old code written by somebody else. And I came across the following snippet:
我正在重构一些由其他人编写的旧代码。我遇到了以下片段:
if (document.all || document.getElementById) {
...
}
When will the code within the if-statement be executed?
if语句中的代码什么时候执行?
Thank you!
谢谢!
回答by Nikola
document.all() is a non-standard way of accessing DOM elements. It's been deprecated from a few browsers. It gives you access to all sub elements on your document.
document.all() 是一种访问 DOM 元素的非标准方式。它已被一些浏览器弃用。它使您可以访问文档中的所有子元素。
document.getElementById() is a standard and fully supported. Each element has a unique id on the document.
document.getElementById() 是标准的并且完全受支持。每个元素在文档上都有一个唯一的 id。

