<dom Scripting>2:dom

Source: Internet
Author: User

DOM (Document Object model).

1 Document: "D" in DOM

When you create a Web page and load it into a browser, the DOM is born quietly. It transforms a Web page document into a Document object.

2 object: "O" in the DOM

Three types of objects in JavaScript:

    • User-defined objects (User-defined object): self-created objects
    • Built-in objects (native object): Objects built into the JavaScript language, such as Array, Math, and Date
    • Host object: Object provided by the browser

3 model: "M" in the DOM

The DOM represents the current page loaded into the browser window; The DOM represents a document as a tree.

4 nodes

A document is a collection of nodes

4.1 ELEMENT nodes

The atomic element node of the DOM, where elements are laid out in the document, forms the structure of the document. The name of the HTML tag is the name of the element.

4.2 Text nodes

The text node is always contained inside the element node.

4.3 Attribute nodes

The attribute node (attribute node) is used to make a more specific description of the element.

4.4 CSS

4.5 Getting elements

    • getElementById: Returns an object that corresponds to an element node with the given ID attribute value: document.getElementById (ID)
    • getElementsByTagName: Returns an array of objects for the element of the given label: element.getelementbytagname (TAG)
    • Getelementsbyclassname: An array of objects that return the elements of the given class attribute: Element.getelementsbyclassname (Class)

5 Getting and setting properties

    • GetAttribute:object.getAttribute (attribute)
    • SetAttribute:object.setAttribute (attribute, value)

<dom Scripting>2:dom

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.