The DOM Document Object Model is an HTML and XML application interface (API). DOM plans the entire page as a document composed of nodes. DOM objects give developers access to HTML, and enable developers to process and view HTML as XML documents. The DOM object is a language-independent API, which means that its implementation is not bound to javascript. This means that beginners may understand the error. DOM is a tree-based API for XML. It focuses not only on Parsing XML code, but on expressing the code with a series of correlated objects, which can be modified, in addition, you do not need to parse the code again to directly access them. Because DOM is easy to use, it becomes the favorite method of Web browsers and javascript. The documentobject is a bomobject, that is, the uploaded Doc ument = document, but it also belongs to DOM, which is also a form of representation of the html dom HTMLDocument object. In other words, it is also an xml dom Document Object.
Most of the DOM processing in JavaScript uses the document Object.
To access html elements, you can use the documentElement feature of document:
Var ohtml#document.doc umentElement;
The oHtml object contains an HTMLElement object that represents
Var oHead = oHtml. firstChild;
Var oBody = oHtml. lastChild;
You can get the objects that represent
Var oHead = oHtml. childNodes [0]; // use childNodes as an Array;
Var oBody = oHtml. childNodes [1]; // use childNodes as an Array;
The above expression can be more formal, that is, the shiyongitem () method:
Var oHead = oHtml. childNodes. item (0 );
Var oBody = oHtml. childNodes. item (1 );
In fact, the DOM object on the HTML page defines document. body as a pointer to the <body/> element, that is
OBody = document. body;
However, document. head is not defined, and its return value is undefined;