1. Obtain the information by label name

 let ulEle = document.getElementsByTagName("ul")[0];
 console.log(ulEle);
Copy the code

2. Get the element from the attribute value of name

 let inputEle = document.getElementsByName("f70")[0];
 console.log(inputEle);
Copy the code

3. Get elements by ID value

 let liEle = document.getElementById("box");
 console.log(liEle);
Copy the code

4. Get elements by class name

 let leiName = document.getElementsByClassName("F70");
 console.log(leiName[2]);
Copy the code

5. Get the parent element

– 1, obtain an element (child element) -2, find the parent element through the element

let navEle = document.getElementsByTagName("nav")[0]; console.log(navEle); ParentNode let headerEle = navele. parentNode; console.log(headerEle);Copy the code

6. Get the child element node

// Format: parent. Children let Eles1 = headerele.children; console.log(Eles1);Copy the code

7. Get child nodes (elements, text, comments)

// Format: parent. ChildNodes let Eles2 = headerele.childnodes; console.log(Eles2);Copy the code

Obtain the first child node

 let FEles = headerEle.firstChild;
 console.log(FEles); 
Copy the code

9. Get the first child node

FEles = headerEle.firstElementChild;
// console.log(FEles); 
Copy the code

10. Obtain the last child node

// let LEles = headerEle.lastChild;
// console.log(LEles); 
Copy the code

11. Get the last child node

LEles = headerEle.lastElementChild;
// console.log(LEles); 
Copy the code