1. Get the element with the specified id: document.getElementById("specified id value");
2. Get the element based on the specified name attribute: document.getElementsByName("set The value of the specified name attribute");
3. Get all elements of the specified tag name: document.getElementsByTagName("Specified tag name");
4. Custom method , find all elements with the same value based on the value of the given class attribute: /**
*? Query all tags containing the specified class value.
*?@param?className?Specified class name, type: String.
*?@param?parent?Parent node, if not filled in, the search will start from the body tag by default, type: HTTPDocument.
*?return?Returns all found elements, type: Array
*/
function?getElementsByClassName(className,?parent){
parent?=?(parent?==?undefineddocument.body?:?parent);
var?childrenList?=?parent.children;
var?i ?=?0,?len?=?childrenList.length;
var?list?=?[];
while(?i?
var?list?=?[];
while(?i? p>
var?nowNode?=?childrenList[i];
var?classNames?=?nowNode.className.split("?");
var?j ?=?0,?lenj?=?classNames.length;
while(?j?
if(nowNode.className?===?classNames [j]){
list.push(nowNode);
break;
}
j++;
< p>}var?cList?=?[];
if(?nowNode.children.length?>?0?){
cList? =?getElementsByClassName(className,?nowNode);
}
list?=?list.concat(cList);
i++;
< p>}return?list;
}