opjects
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.
property is a variable is part of an object
method is a function is part of an object
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.
THE DOM TREE 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.
- THE DOCUMENT NODE
- ELEMENT NODES
- ATTRIBUTE NODES
-
TEXT NODES
- U CAN LOOP THROUGH A NODELIST
ADDING ELEMENTS USING DOM MANIPULATION DOM manipulation offers another technique to add new content to a page (rather than i nnerHTML). It involves three steps
- CREATE THE ELEMENT createEl ement ()
- GIVE IT CONTENT createTextNode()
- ADD IT TO THE DOM appendChild()
REMOVING ELEMENTS VIA DOM MANIPULATION DOM manipulation can be used to remove elements from the DOM tree.
- 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