Objects, and the DOM

Chapter 3 “Object Literals”

Object & Method

Example with some lines of code

object-firstCode




Chapter 5: “Document Object Model (DOM)”

DOM Tree

DOM Contains 4 Types of Nodes :: Each Node Is an Object With Methods and Properties :

  1. The Document Node it represents the entire page.
  2. Element Nodes HTML elements describe the structure of an HTML page. (The <h l > - <h6> elements describe what parts are headings; the <p> tags indicate where.
  3. Attribute Nodes The opening tags of HTML elements can carry attributes and these are represented by attribute nodes in the DOM tree. Attribute nodes are not children of the element that carries them; they are part of that element
  4. Text Nodes Once you have accessed an element node, you can then reach the text within that element. This is stored in its own text node.

Accessing and updating the DOM tree involves two steps:

  1. Locate the node that represents the element you want to work with.
  2. Use its text content, child elements, and attributes.

Working with The DOM Tree