Document Object Model (DOM) is a standard programming interface recommended by W3C for processing Extensible slogans.
DOM = Document Object Model, Document Object Model. DOM can access and modify the content and structure of a Document in a way independent of platform and language. In other words, this is a common way to represent and process an HTML or XML document.
I. Read-Only attributes of dom objects
*. FirstChild returns an object, indicating the first subnode of the current node.
*. LastChild returns an object, indicating the last subnode of the current node.
*. NextSibling returns an object, indicating the next sibling node of the current node.
*. Previussibling returns an object, indicating the previous sibling node of the current node.
*. ParentNode returns an object, indicating the parent object of the current node.
*. NodeName returns a string indicating the html tag of the current node.
*. NodeType returns a number. 1 indicates the tag, 2 indicates the attribute, and 3 indicates the text item.
Ii. read/write attributes of dom objects
*. NodeValue returns a string that indicates the value of a text item. If it is a node of another type, null is returned.
*. Data returns a string that indicates the value of a text item. If it is a node of another type, undefined is returned.
Summary: because these attributes can be written, we can dynamically modify Foreground Data, for example (text node. nodeValue = "dynamic value"
3. Set attributes of dom objects
*. ChildNodes returns an array of objects, indicating the collection of all child nodes of the current node.
*. Attributes returns an array of objects, indicating all attribute sets of the current node, accessed by id, such as attributes. id or cn2.border example: attributes. border. nodeValue = 10, but it is generally not used this way, because it is easier to use.
4. Common dom Methods
*. DocumentElement: document.doc umentElement. nodeName
*. ActiveElement: return the active tag node in the current document, for example, document. activeElement. nodeName.
*. CreateElement (sNode) adds a label node. The parameter is named "var newnode = document. createElement (" div ")
*. CreateTextNode (text): Create a node that contains static text. For example, var newText = document. createTextNode ("Create a node that contains static text ");
*. Document. createAttribute ("name") Create an attribute
*. Document. createComment () Create comments
*. Document. createStyleSheet (); Create a style
*. Document. createEventObject () Create an event object
*. Always use the first two
*. AppendChild (oNode): table (a source node). appendChild (oNode (a new node ));
*. RemoveChild (oNode): table (a source node). removeChild (oNode );
*. GetAttribute (name): tablenode. getAttribute ("border ")
*. SetAttribute (name, value): tablenode. setAttribute ("border", 10 );
*. InsertBefore (newNode, targetNode) inserts a new newNode node before the target node targetNode.
*. RemoveNode (name) deletes the node named after name.
*. ReplaceNode (newNode, oldNode) replaces oldNode with newNode
*. HasChildNodes returns a Boolean value to determine whether a subnode exists.