Connecting Tech Pros Worldwide Help | Site Map

document.all vs. document.getElementById

  #1  
Old September 3rd, 2007, 01:03 PM
Newbie
 
Join Date: Sep 2007
Posts: 2
what is the difference b/w document.all() and document.getElementById()
  #2  
Old September 3rd, 2007, 05:10 PM
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,634
Provided Answers: 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
  #3  
Old September 4th, 2007, 05:14 AM
sumittyagi's Avatar
Expert
 
Join Date: Mar 2007
Location: New Delhi, India
Posts: 198

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.
  #4  
Old September 4th, 2007, 02:40 PM
prometheuzz's Avatar
Editor
 
Join Date: Apr 2007
Location: Rotterdam, the Netherlands.
Posts: 190

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.
  #5  
Old September 4th, 2007, 02:47 PM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: document.all vs. document.getElementById


hi ...

please ... always use a good thread title

kind regards
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
innerHTML vs. replaceChild() Hallvard B Furuseth answers 9 March 11th, 2006 07:15 AM
document.all vs. document.layers yawnmoth answers 2 December 24th, 2005 01:25 PM
document.all vs. document.getElementByID Martin answers 2 December 12th, 2005 09:55 PM
document.tagID vs document.all.tagID chirs answers 1 July 20th, 2005 01:27 PM