Connecting Tech Pros Worldwide Forums | Help | Site Map

document.all vs. document.getElementById

Newbie
 
Join Date: Sep 2007
Posts: 2
#1: Sep 3 '07
what is the difference b/w document.all() and document.getElementById()

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Sep 3 '07

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
sumittyagi's Avatar
Expert
 
Join Date: Mar 2007
Location: New Delhi, India
Posts: 198
#3: Sep 4 '07

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.
prometheuzz's Avatar
Editor
 
Join Date: Apr 2007
Location: Rotterdam, the Netherlands.
Posts: 189
#4: Sep 4 '07

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.
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#5: Sep 4 '07

re: document.all vs. document.getElementById


hi ...

please ... always use a good thread title

kind regards
Reply