JS Method for accessing the DOM object specified node

The instance of this paper describes the method of JS implementation to access the DOM object specified node. Share to everyone for reference, specifically:

Use the getElementById ()

method to access the node of the specified ID, and use nodename Attributes, NodeType properties, and NodeValue properties to display the node name, node type, and node value.

1, NodeName attribute

This property is used to get the name of a certain node. [SNAME =] Obj.NodeName

SNAME: String variable is used to store the name of the node.

2, NodeType Attributes

This property is used to get the type of a certain node.

[23] Obj.NodeType

STYPE: String variable, used to store the type of node, which value is numerical. The type of the parameter is shown in the table below.

Type Numeric Name


Mark 2 In the markAttribute Text 3 #Text contains text in the mark Note 3, attribute This property will return The value of the node. TXT: The string variable is used to store the value of the node. Except for the text node type, other types of node values ​​are NULL.
DocumentType 10 DOCTYPE
NodeValue Obj.NodeValue

Access the specified node, this example is in the page pop-up prompt box, which shows the name of the node, the type, and the value of the node.

WWW.JB51.NET Access Specified Node

Bold content

      Four running pops up the following prompt box:    

More about JavaScript-related content, readers who are interested in this site: "JavaScript operation DOM skill summary", "JavaScript error and debugging skill summary", "JavaScript data structure and algorithm skill summary", "JavaScript multi-pass algorithm and skill summary" And "Summary of JavaScript Mathematical Computing" I hope this article will help you JavaScript programming.
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment