This article summarizes the method of finding nodes by js. Share it for your reference. The specific analysis is as follows:
Here are three ways to find nodes:
1. Search according to the id, and the return value is an object: the copy code is as follows: document.getElementById();
2. Search according to the html tags such as div/p/..., and return the array (actually also an object) and copy the code as follows: document.getElementsByTagName();
3. Use it in the form and find the copy code according to the form name as follows: document.getElementsByName();
Special note: At present, some browsers have extended getElementsByName to other element nodes, i.e., if the tags such as div/p... have name attributes, they can also be used; but IE browser can only be used in forms. Therefore, to maintain compatibility, it should only be used in the form when using it.
I hope this article will be helpful to everyone's JavaScript programming.