Summary of "Javascript" HTML dom knowledge points

Source: Internet
Author: User

1. What is the DOM (Document Object model)
The DOM defines the standard for accessing HTML and XML documents: it stands on the platform and Language interface, which allows programs and scripts to dynamically access and update the content, structure, and style of the document.
HTML DOM-A standard model for HTML documents. In other words, the HTML DOM is the standard for how to get, modify, add, or delete HTML elements.
2. DOM node
All content in an HTML document is a node:

    a 整个文档是一个文档节点    b 每个 HTML 元素是元素节点    c HTML 元素内的文本是文本节点    d 每个 HTML 属性是属性节点    e 注释是注释节点* **父节点 子节点 兄弟节点 可以类比数据结构来思考**。*

3.DOM method
Methods are actions that we can perform in a node (that is, HTML).
All HTML elements are defined as objects, while programming interfaces are object methods and object properties. Methods are actions that you can perform (such as adding or modifying elements). A property is a value that you can get or set (such as the name or content of a node). For example I am an object (can imagine oneself is a beautiful female programmer, yes, yes!) ), I can do the action (that is, the method) has eat (), coding (), study () and so on; I also have my own properties including height, weight and age.
Some common HTML DOM methods:
getElementById (ID)-Gets the node (element) with the specified ID
AppendChild (node)-Insert a new child node (element)
RemoveChild (node)-Delete child nodes (elements)
4.DOM Properties
The InnerHTML property is useful for getting or replacing the contents of an HTML element.
5. Accessing HTML DOM-finding HTML elements
Accessing HTML elements is equivalent to accessing nodes
document.getElementById ("id"); Gets the element in the ID
document.getElementsByTagName ("P"); Returns all elements with the specified label name (here is the label P). You can use arrays to represent the first few tags
Document.getelementsbyclassname ("classname");//All HTML elements with the same class name
Getelementsbyclassname () is not valid in Internet Explorer 5,6,7,8.

Summary of "Javascript" HTML dom knowledge points

Related Article

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.