JavaScript basic Operations

Source: Internet
Author: User
Tags tag name

1. What is DOM
Dom is the short name of the Document Object model, and its basic idea is to parse the structured document into a series of nodes, and then make a tree-like structure from these nodes. The final tree structure of all nodes has a canonical external interface to achieve the purpose of manipulating the document using the programming language, so that the DOM can be understood as a form of a document's transformation.
Strictly speaking, Dom is not a JavaScript, but manipulating the DOM is the most common task of JavaScript, and JavaScript is the most commonly used language for DOM manipulation.

2. Node
The smallest component of a DOM is called a node, and a document's tree structure is made up of various types of nodes.
The six main nodes are as follows:
1.Document document node entire document (Window.document)
Type of 2.DocumentType document type node document
3.Element element node HTML elements (e.g. Attributes of the 4.Attribute attribute node HTML element (e.g. class= "right")
Text that appears in a 5.Text text node HTML document
Fragment of a 6.DocumentFragment document fragment node document

3. Select Document elements
1. By ID:document.getElementById ("Idname")
2. Find the element by name or tag name: Getelementsbyname () method or getElementsByTagName () method, but if there are multiple
3. Querying and setting the attributes of an element: GetAttribute (), SetAttribute ()
4. Father node: The parent node of the current node can be manipulated by the ParentNode () method
5. Creating and Inserting Nodes: createelement (), AppendChild ()
Creating a node with the createelement () method
Inserting a node through the Appendelement () method
6. Deletion of nodes: RemoveChild ()

JavaScript basic Operations

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.