HTML & Javascript

Chapter 3.FUNCTIONS, METHODS & OBJECTS

creating an object:literal notation

literal notation is the easiest and most populer way to create objects.

when setting properties, treat the values like you would do for variables:strings live in quotes and arrays live in square brackets.

accessing an object and dot notation

you access the properties or methods of an object using dotnotation. you can also access properties isong square brackets.

dot notation or square brackets

To access a property or method of an object you can use the name of the object, followed by a period, then the name of the property or method you want to access(this is known as dot notation).

you can also access the property of an object using square bracket syntax.

This notation is used most commonly used when:

  • The name of property is a number.
  • A varible is being used in place of the property name.

dot notation

dot notation

Chapter 5.DOCUMENT OBJECT MODEL

tree

tree

tree

document object model summary

  • The browser represents the page using a DOM tree.
  • DOM trees have four types of nodes: document nodes, element nodes, attribute nodes, and text nodes.
  • You can select element nodes by their id or cl ass attributes, by tag name, or using CSS selector syntax.
  • Whenever a DOM query can return more than one node, it will always return a Nadel i st.
  • From an element node, you can access and update its content using properties such as textContent and i nnerHTML or using DOM manipulation techniques.
  • An element node can contain multiple text nodes and child elements that are siblings of each other.
  • In older browsers, implementation of the DOM is inconsistent (and is a popular reason for using jQuery).
  • Browsers offer tools for viewing the DOM tree .