Basic notes for javascript learning-DOM object operation_javascript skills
Source: Internet
Author: User
Javascript is an object-based and world-driven scripting language with high security. A complete javascript implementation includes the core (ECMAScript), the Document Object Model (DOM), and the browser Object Model (BOM). The DOM Document Object Model is an application interface (API) of HTML and XML ), 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 a representation.The HTMLElement object of, through:
Var oHead = oHtml. firstChild;
Var oBody = oHtml. lastChild;
You can obtain the representation respectively.AndYou can also use the childNodes feature to complete:
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 pointElement pointer, that is
OBody = document. body;
However, document. head is not defined, and its return value is undefined;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.