Old version Get node
1. Get body
Console.log (document.body);
2. Get img
Console.log (document.images);
3. Get a tag
Console.log (document.links);
4. Get a label containing the name attribute
Console.log (document.anchors);
5. Get Form Label
Console.log (document.forms);
Methods to get Nodes
New version gets node method: DOM2
1, through the ID gets, can be given a variable to save (in parentheses write ID name)
Let A = document.getElementById ("box");
Console.log (a);
2. Get through Class (get an array)
Console.log (Document.getelementsbyclassname ("1"));
3, obtained by the tag name (gets the array)
Console.log (document.getElementsByTagName ("div"));
4, obtained by the Name property (Gets the array)
Console.log (Document.getelementsbyname (2));
HTML5 Get Node method
1. Gets the first tag that satisfies the selector (the CSS selector is written in parentheses)
Console.log (Document.queryselector (". Box1>p"));
2. Get an array (the CSS selector is written in parentheses)
Console.log (Document.queryselectorall (". Box1>p"));
JS Get Node method