Connecting Tech Pros Worldwide Help | Site Map

document.all vs. document.getElementById

 
LinkBack Thread Tools Search this Thread
  #1  
Old September 3rd, 2007, 12:03 PM
Newbie
 
Join Date: Sep 2007
Posts: 2
Default document.all vs. document.getElementById

what is the difference b/w document.all() and document.getElementById()
Reply
  #2  
Old September 3rd, 2007, 04:10 PM
JosAH's Avatar
Moderator
 
Join Date: Mar 2007
Location: Voorschoten, the Netherlands
Age: 52
Posts: 10,038
Default

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
  #3  
Old September 4th, 2007, 04:14 AM
sumittyagi's Avatar
Expert
 
Join Date: Mar 2007
Location: New Delhi, India
Age: 27
Posts: 183
Default

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

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
  #5  
Old September 4th, 2007, 01:47 PM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Age: 37
Posts: 3,780
Default

hi ...

please ... always use a good thread title

kind regards
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.