PDA

View Full Version : Difference between getElementById and getElementByTag



sathishhc
07-25-2006, 07:08 AM
Please any one can tell me what is difference between getElementById and getElementByTag.

jscheuer1
07-25-2006, 08:03 AM
One, getElementById() is a valid javascript object method, the other is not (although a function could be written to create it as one if you wanted to). But, perhaps you mean getElementsByTagName() - that is also a valid javascript object method. The difference is that ElementById will retrieve a single element object with the unique id specified, whereas ElementsByTagName will retrieve an array of all element objects with the specified tag name.