---restore content starts---
The HTML document can be said to be a collection of nodes, the DOM nodes are:
1). ELEMENT nodes:
2). Text node: Content that is presented to the user, such as JavaScript, DOM, CSS, and other text in <li>...</li>.
3). Attribute node: element properties, such as the <a> tag's link property href= "http://www.imooc.com".
1. Node Properties:
2. Traverse the node tree:
3. Dom Operation:
4.Getelementsbyname () method
// Syntax document.getelementsbyname (name)
Attention:
1) because the Name property in the document may not be unique, all getelementsbyname () methods return an array of elements, not an element.
2) and arrays similar also have the Length property, which can be accessed in the same way as an array of accesses, starting with 0.
//Examplefunction Getnum () {varMynode=document.getelementsbyname ("MYT") ; alert (mynode.length);}</script><input name="MYT"Type="text"Value="1"><input name="MYT"Type="text"Value="2"><input name="MYT"Type="text"Value="3"><input name="MYT"Type="text"Value="4"><input name="MYT"Type="text"Value="5"><input name="MYT"Type="text"Value="6"><input type="Button"onclick="Getnum ()"Value="How many items are there? "/>//gets the name of the element that is MYT, and outputs the length of the element node that is obtained.
5,getElementsByTagName () method: Returns the collection of node objects with the specified label name. The order in which elements are returned is their order in the document.
// Grammar document.getelementsbytagname (Tagname)
Description
1) tagname is the name of the label, such as P, A, IMG and other label names.
2) and arrays similar also have the Length property, which can be accessed in the same way as an array of accesses, so starting from 0.
//Examplefunction Getnum () {varMynode=document.getelementsbytagname ("input") ; alert (mynode.length);}</script><input type="text"Value="1"><input type="text"Value="2"><input type="text"Value="3"><input type="Button"onclick="Getnum ()"Value="See how many input tags are there? "/>//gets the input tag, and outputs the length of the element node that gets.
JavaScript's Dom (Document object) Basic Syntax summary 1