Javascript: Getelementbyid Vs Getelementsbyid (both Works On Different Pages)
Solution 1:
As described by James
hereid values have to be unique in a document, so there will be only one "element" that matches, rather than multiple "elements".
That is the reason, We should not use s while selecting elements. As Id
can be selected only one at a time.
However, there are methods that return multiple elements which do use the plural "elements", such as getElementsByTagName
.
Hope that clears your confusion
Solution 2:
First things first: Function-, or rather, methodnames in JavaScript are Case-Sensitive. This means that document.getElementById is not the same as document.getElementbyId.
The weird part: document.getElementsById does not exsist in JavaScript, so it can't work by default. The only way this can work is if somebody created this function/method on the other page. A more obvious explanation is that you made a type-o on your second page. Maybe you forgot to write the S and you thought you didn't. Can you try again?
Post a Comment for "Javascript: Getelementbyid Vs Getelementsbyid (both Works On Different Pages)"