Why Nobody Cares About document getelementsbytagname
The problem with this function and the document.getElementsByTagName() function is that they can only be called on the document object. If your document is an instance of a class, that class has the document method (that can be called on any object).
For example, let’s say that you want to get a list of all the links on a page. That might seem as though it would be easy, but as you can imagine, this isnt such a simple task. The document.getElementsByTagName function is the only one that can actually be called on the document, so you cant just call it on the document itself. It has to be called on the instance that has the document.
We can use the method document.getElementByTagName to get the element by tag name. That is, if we have a document that has the element, then we could do something like document.getElementsByTagName(‘head’), but this isnt the correct method to use. The correct method is document.getElementById, but the problem is that the document is an instance of the document object, which is not an instance of a node.
So we have to do document.getElementById. This has gotten to be a problem lately because some developers think that it is a bad idea to use the document.getElementById method because document.getElementById is an instance method on the document object. I personally think that it is a good idea to use the document.getElementByTagName method, but the method to use is document.getElementById.
It’s kind of a shame that the method to use is document.getElementById, because there are some really cool ways to interact with the document object. You can read data from it, you can call methods on it, you can use it as an array in an array, you can set its size, and you can create new elements. There are a bunch of other things that document.getElementById is really good at.
If you’re going to use document.getElementById for multiple elements on pages, you should really use it for multiple elements on the page. Otherwise you can mess things up. Let’s say you have a page with seven elements, and you were going to use this method to access element number two. But on another page, you have a different ID for element number two. Oops.
You’ve now had your element ID wrong twice, so now you’re going to have to do it over again. That’s the beauty of having a website, is that you can keep things nice and clean.
If you have multiple pages on your site and you should use the same ID for multiple pages, don’t mix them up. You can assign a different ID if you want to be extra careful. You can also use the ID in another place altogether, like in the URL if you want.
If you need to get to the same ID in different places, you can use the element ID in the URL. On the page where you use the element ID, you can change it to whatever ID you need.