The DOM is divided into three parts:
(1) core dom: Traverse Dom tree, Add new node, Delete node, Modify node
(2) HTML dom: Accessing the DOM tree in an easy way
(3) XML DOM: quasi for manipulating XML documents
The difference between the core DOM and the HTML dom:
Core dom:
Object: document,node, Elementnode,textnode,attributenode,commentnode,nodelist
The core DOM provides a unified operating interface
CreateElement
AppendChild
SetAttribute
RemoveAttribute
NodeName
...
The core DOM creates a new element:
var newnode=document.createelement ("img")
To add an attribute to an element:
E.setattribure (",")
E.setAttriburenode (attr)
Applicable occasions:
The core DOM is suitable for manipulating nodes, such as creating, deleting, finding, etc.
HTML DOM:
Object: Image,table,form,input,select ... HTML Tag Object
Note: tablecell:td;tablerow:tr
HTML DOM provides a variety of encapsulated objects
Image
Select
Option
...
HTML DOM creates new elements
var newnode=new Image ();
To add an attribute to an element:
Img.src= ";
Img.id= ";
Imd.title= ";
Img.classname= "
img.style.display= ";
This is a typical HTML DOM method that will create elements and access the attributes of the Elements. these methods are simplified, and the attributes are directly treated as properties of the object, but we should pay attention to Img.classname= '
Applicable occasions:
HTML Dom is suitable for manipulating properties, such as reading or modifying the value of a property
The difference between the core DOM and the HTML DOM