| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Registered User
Join Date: Mar 2008
Posts: 23
|
get element by id & get document.all
Hi I need to find some information on the two things in the thread title. Ive had a little search around but nothing really explains the two properly. Thanks if you can explain it or have a decent link =] |
|
|
|
|
|
#2 (permalink) |
|
Moderator
Join Date: Jan 2005
Location: Brooklyn, NYC
Posts: 11,869
|
document.getElementById is a standard W3C DOM method for finding an element by ... get ready ... its ID. document.all is bad, bad, bad. Find good advice in the beginners web design thread.
patrick o'neill web developer | blog | spam humor |
|
|
|
#3 (permalink) |
|
Registered User
Join Date: May 2008
Location: Seattle
Posts: 9
|
pgo said it, I'll just throw out some notes: document.all is a reaaaaally old and outdated method of grabbing something in the page. getElementById does the same thing, but is now the preferred method, and is part of the standard, so it will continue to be supported well into the future, whereas document.all won't be. For getElementById, The ID in question is the HTML attribute "ID", which can be applied to almost every element. It's meant to be a unique identifier, so if (heaven forbid) you had two elements with the same ID, it should only ever return the first one on the page. |
|
![]() |