SoFunction
Updated on 2025-02-28

DOM object operation of basic notes in javascript

The DOM document object model is an application program interface (API) of HTML and XML. The DOM plans the entire page into a document composed of node hierarchy. DOM objects give developers access to HTML and enable developers to process and view HTML as XML documents. DOM objects are language-independent APIs, meaning that their implementation is not bound to javascript, which is something that beginners may understand errors. DOM is a tree-based API for XML. It focuses on not just parsing XML code, but representing this code with a series of interrelated objects that can be modified and can directly access them without re-parsing the code. Due to the ease of use of DOM, it has become the favorite method for web browsers and javascript. The document object is an object of the BOM, that is, ==document, but it also belongs to the DOM and is also a manifestation of the HTMLDocument object of the HTML DOM. Conversely, it is also an XML DOM Document object.

Most of the DOM processing processes in JavaScript use document objects.

To access the html element, you can take advantage of the document's documentElement feature:

var oHtml=;

The oHtml object contains an HTMLElement object representing <html/>, through:

var oHead=;

var oBody=;

You can get objects representing <head/> and <body/> respectively, or you can do it by using the childNodes feature:

var oHead=[0]; //Use childNodes as Array;

var oBody=[1]; //Use childNodes as Array;

The above expression can use a more formal expression method, that is, the shiyongitem() method:

var oHead=(0);

var oBody=(1);

In fact, in the HTML page DOM object defines a pointer to the <body/> element, that is,

oBody = ;

But it has no definition, its return value is undefined;