Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

document.all vs. document.getElementById

Question posted by: vin21 (Newbie) on September 3rd, 2007 12:03 PM
what is the difference b/w document.all() and document.getElementById()
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
JosAH's Avatar
JosAH
Chief Editor
7,525 Posts
September 3rd, 2007
04:10 PM
#2

Re: document.all vs. document.getElementById
Quote:
Originally Posted by vin21
what is the difference b/w document.all() and document.getElementById()


You should ask your Java questions in the Java Forum section, not the Java
Articles section. I'll move your question to the Java Forum section.

kind regards,

Jos

Reply
sumittyagi's Avatar
sumittyagi
Expert
183 Posts
September 4th, 2007
04:14 AM
#3

Re: document.all vs. document.getElementById
Quote:
Originally Posted by vin21
what is the difference b/w document.all() and document.getElementById()


This question is of javascript, you should ask javascript questions in javascript forum, not in java forum. You will be guided there better.

document.all() is a non-standard way of accessing DOM elements. It was originally started by IE. Other browsers either depricated it or don't support it. document.all gives you access to all the elements on your element.

On the other hand document.getElementById is a standard way of accessing the elements on the document. Each element have a unique id on the document which can be defined by id attribute of that element.

So if you have <div id="abc"></div>

and you do document.getElementById("abc"); then you will have access to that div.
But remember never give same ids to two different elements, else you could have unexpected results.

Reply
prometheuzz's Avatar
prometheuzz
Editor
190 Posts
September 4th, 2007
01:40 PM
#4

Re: document.all vs. document.getElementById
Quote:
Originally Posted by sumittyagi
This question is of javascript, you should ask javascript questions in javascript forum, not in java forum. You will be guided there better.
...


Moved it to the JavaScript forum.

Reply
gits's Avatar
gits
Moderator
3,153 Posts
September 4th, 2007
01:47 PM
#5

Re: document.all vs. document.getElementById
hi ...

please ... always use a good thread title

kind regards

Reply
Reply
Not the answer you were looking for? Post your question . . .
183,940 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Javascript / DHTML / Ajax Forum Contributors