document.all是什么意思? [英] What does document.all mean?
本文介绍了document.all是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我'重构一些别人写的旧代码。我发现了以下代码段:
I'm refactoring some old code written by somebody else. And I came across the following snippet:
if (document.all || document.getElementById) {
...
}
if语句中的代码何时执行?
When will the code within the if-statement be executed?
谢谢!
推荐答案
document.all()是非标准的访问DOM元素的方式。它已被少数浏览器弃用。它允许您访问文档中的所有子元素。
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.getElementById()是标准且完全支持。每个元素在文档上都有唯一的ID。
document.getElementById() is a standard and fully supported. Each element has a unique id on the document.
这篇关于document.all是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文