HTML DOM Summary

Source: Internet
Author: User

Definition of MDN

The Document Object Model (DOM) is the programming interface for HTML and XML documents. It provides a structured representation of the document (the tree) and defines a way in which the program can access the tree to change the structure, style, and content of the document. The DOM provides a representation of the document as a structured node group and an object that contains properties and methods. Essentially, it connects web pages to scripts or programming languages.

Dom Core API

In DOM programming, the most commonly used is the document and Window objects. The Window object represents the content in the browser, which is the root element. The Document object is the root node of the documentation itself. Element inherits the common Node interface

  
 
  1. document.getElementById(id)
  2. element.getElementsByTagName(name)
  3. document.createElement(name)
  4. parentNode.appendChild(node)
  5. element.innerHTML
  6. element.style.left
  7. element.setAttribute
  8. element.getAttribute
  9. element.addEventListener
  10. window.onload
Interfaces and objects

Many objects are implemented on several different interfaces. For example, the Table object implements the HTML table element Interface, because the Table object is also an HTML element, so it also implements the element interface, and finally, it is a node in the number of nodes, so more basic also implemented the Node interface

Property manipulation
  
 
  1. // 获取一个{name, value}的数组
  2. var attrs = el.attributes;
  3. // 获取、设置属性
  4. var c = el.getAttribute(‘class‘);
  5. el.setAttribute(‘class‘, ‘highlight‘);
  6. // 判断、移除属性
  7. el.hasAttribute(‘class‘);
  8. el.removeAttribute(‘class‘);
  9. // 是否有属性设置
  10. el.hasAttributes();


From for notes (Wiz)

HTML DOM Summary

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.