Method return type description nodeNameString node name nodeValueString node value nodeTypeNumber node type constant value firstChildNode points to the first node in the childNodes list lastChildNode points to the last node childN in the childNodes list...
Method |
Return type |
Description |
NodeName |
String |
Node name |
NodeValue |
String |
Node Value |
NodeType |
Number |
Type constant value of a node |
FirstChild |
Node |
Point to the first node in the childNodes list |
LastChild |
Node |
Point to the last node in the childNodes list |
ChildNodes |
NodeList |
List of all child nodes |
Previussibling |
Node |
Indicates a forward sibling node. If this node is the first sibling node Point, then the value is null |
NextSibling |
Node |
Point to the next sibling node. If this node is the last sibling node Point, then the value is null |
HasChildNodes () |
Boolean |
Returns true if childNodes contains one or more nodes. |
Attributes |
NamedNodeMap |
Contains Attr objects that represent the characteristics of an Element. It is only used for Element Node |
AppendChild (Node) |
Node |
SetNodeAdd to the end of childNodes |
RemoveChild (Node) |
Node |
Delete from childNodesNode |
ReplaceChild (Newnode,Oldnode) |
Node |
In childNodesOldnodeReplaceNewnode |
1 getElementById ()
Note:
1. query the element with the given ID attribute value and return the Element Node of the element. It is also called an element object.
2. Because the id value in an html page is unique, the return value is unique. Therefore, the method name is getElementById () instead of getElementsById ()
3. This method can only be used for document objects, similar to the static keyword of java.
Case:
Var inputDom = document. getElementById ("uname ")
// The attribute value of the current dom object
Alert (inputDom. type + inputDom. value + inputDom. id );
// Element node name label name value is null Element Node Type value 1
Alert (inputDom. nodeName + inputDom. nodeType + inputDom. nodeValue );
2. getElementsByName ()
2.1 note:
1. Search for all elements of the given name attribute. This method returns a node set, also known as an object set.
2. This set can be treated as an array. The value of the length attribute indicates the number of sets.
3. Because name cannot uniquely identify an element on an html page, the method name is getElementsByName instead of getElementByName.
Example:
GetElementsByName.html
User Name
What are your favorite spring festival programs?
111
222
333
444
555
666