I start learning about object
Objects: group together a set of variables and functions to create a model of a something you would recognize from the real world. In an object, variables and functions take on new names.
var hotel = { properties method }
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.
IS A MODEL OF A WEB PAGE As a browser loads a web page, it creates a model of that page. The model is called a DOM tree, and it is stored in the browsers' memory. It consists of four main types of nodes.
Above, you can see the HTML code for a shopping list, and on the right hand page is its DOM tree. Every element, attribute, and piece of text in the HTML is represented by its own DOM node.
HTML elements describe the structure of an HTML page. (The -
getElemenyById() and querySelector() can both search an entire document and return individual elements get El ementByi d () allows you to select a single element node by specifying the value of its id attribute
FROM A NODELIST There are two ways to select an element from a Nodelist: The item() method and array syntax. Both require the index number of the element you want.
querySe 1 ector() returns the first element node that matches the CSS-style selector. querySe 1ectorA11 () returns a Nodelist of all of the matches.
When you have an element node, you can select another element in relation to it using these five properties. This is known as traversing the DOM.
Traversing the DOM can be difficult because some browsers add a text node whenever they come across whitespace between elements.
NODE WITH NODEVALUE When you select a text node, you can retrieve or amend the content of it using the node Va 1 ue property.
Using the i nnerHTML property, you can access and amend the contents of an element, including any child elements.
DOM manipulation offers another technique to add new content to a page (rather than i nnerHTML).
- STORE THE ELEMENT TO BE REMOVED IN A VARIABLE
- STORE THE PARENT OF THAT ELEMENT IN A VARIABLE
- REMOVE THE ELEMENT FROM ITS CONTA INING ELEMENT