Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does document.all mean? [duplicate]

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?

Thank you!

like image 362
Evgenij Reznik Avatar asked Dec 01 '12 19:12

Evgenij Reznik


1 Answers

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() is a standard and fully supported. Each element has a unique id on the document.

like image 129
Nikola Avatar answered Sep 28 '22 09:09

Nikola