what is DOM?
What is called Dom,dom is the Document Object model, which is a set of API interfaces based on browser programming (in this tutorial, which can be said to be DHTML programming), the recommended standards for the Web, and each browser has some subtle differences, Among them, Mozilla's browser is closest to the standard. Simple JavaScript can be combined with DOM to do DHTML programming to make beautiful effects and apply to the Web. This is almost the same as any other language, just as C + + requires library support. Otherwise, it's a purely grammatical study.
Therefore, it is necessary to have a certain understanding of the DOM in order to apply JavaScript to the Web.
Let me tell you a little bit about how DOM operates:
Create a Node
var createnode = document.createelement ("div");
var createTextNode = document.createTextNode ("Hello World");
Createnode.appendchild (createTextNode);
Document.body.appendChild (CreateNode);
Document.documentElement.appendChild (CreateNode);
Inserting nodes
var createnode = document.createelement ("div");
var createTextNode = document.createTextNode ("Hello World");
Createnode.appendchild (createTextNode);
var div1 = document.getElementById ("Div1");
Document.body.insertBefore (CREATENODE,DIV1);
Replace element
var replacechild = Document.body.replaceChild (CREATENODE,DIV1);
Delete Element
var removechild = Document.body.removeChild (DIV1);
Finally, let us summarize:
The DOM standard is divided into 3 different parts:
Core DOM-a standard model for any structured document
XML DOM-a standard model for XML documents
HTML DOM-A standard model for HTML documents
All content in an HTML document is a node, based on the HTML DOM standard of the paper:
The entire document is a document node
Each HTML element is an element node
Text within an HTML element is a text node
Each HTML attribute is an attribute node
Comment is a comment node
Some common HTML DOM methods:
getElementById (ID)-Gets the node (element) with the specified ID
AppendChild (node)-Insert a new child node (element)
RemoveChild (node)-Delete child nodes (elements)
Some common HTML DOM properties:
InnerHTML-Text value of the node (element)
ParentNode-parent node of the node (element)
ChildNodes-Child nodes of nodes (elements)
Attributes-node (element) attribute node
If you do not understand, please click the following reference:
Reference
JS Operation Dom