reading_notes

Read: 06 - JS Object Literals; The DOM:

Objects:

Objects group together a set of variables and functions to create a model of a something you would recognize from the real world.

Example:

Object

Creating an Object: Literal notation:

Literal notation


Document Object Model (DOM):

The Document Object Model (DOM) specifies how browsers should create a model of an HTML page and how JavaScript can access and update the contents of a web page while it is in the browser window.

DOM benefits

DOM model

Methods to return elements:

Return single element:

Return single element

Return multiple elements:

Return multiple elements

getElementbyID:

getelementbyid

Nodelist:

Live and static Nodelists:

Looping through a nodelist:

Looping

Traversing the DOM:

You can do it by using 5 properties: parentNode, previousSibling/nextSibling, firstChild/lastChild

DOM Tree

Adding elements using DOM manipulation:

  1. Create the element: createElement( )
  2. Give it content: createTextNode ( ) * you can skip if you add empty element
  3. add it to the DOM: appendChild ( )

Attribute Nodes:


Understanding the problem domain is the hardest part of programming:

If understanding the problem domain is the hardest part of programming and you want to make programming easier, you can do one of two things: