Làm web (js06) - JS: DOM

Bài trước: Làm web (js05) - JS: Objects
----------

6 DOM


The Document Object Model (DOM) allows you to access elements of a web page and enable interaction with the page by adding and removing elements, changing the order, content and attributes of elements, and even altering how they are styled.
In this chapter, we’ll cover the following topics:

– Introduction to the DOM

– Getting elements: getElementById, getElementsByClassName, getElementsByTagName, querySelector and querySelectorAll

– Navigating the DOM

– Getting and settings an element’s attributes

– Updating the DOM by creating dynamic markup

– Changing the CSS of an element

– Our project: we’ll dynamically insert each question into the HTML

6.1 The Document Object Model


What is DOM?

The Document Object Model, or DOM for short, represents an HTML document as a network of connected nodes that form a tree-like structure.

The DOM treats everything on a web page as a node. HTML tags, the text inside these tags, even the attributes of a tag are all nodes. The HTML tag is the root node, and every other part of the document is a child node of this.

History of the DOM (p218)

6.2 Getting elements (p221)


6.3 Setting an element’s attributes (p233)


6.4 Creating dynamic markup (p237)


-----
Cập nhật: 15/12/2019
-----
Xem thêm: Làm web (js07) - JS: Event
Xem thêm: Danh sách bài học