Document Object Model (DOM) :

* The Document Object Model (DOM) is the model that describes how all elements in an HTML page (like input fields, images, paragraphs etc.) are related to the topmost structure: the document itself.

* It defines the logical structure of documents and the way a document is accessed and manipulated.

* Each HTML document loaded into a browser window becomes a Document object. The Document object provides access to all HTML elements in a page, from within a script.

Document :

Represents the entire HTML document and can be used to access all elements in a page

Document object methods :

getElementById()

getElementsByTagName()

Node methods

createElement()

appendChild()

removeChild()

getAttribute()

setAttribute()

createElement(tagName)

createAttribute("attributename")

document.forms

Window Object :

The window object represents an open window in a browser. It is the top level object in JavaScript, and contains in itself several other objects, such as "document" etc.

Note : If a document contain frames (<frame> or <iframe> tags), the browser creates one window object for the HTML document, and one additional window object for each frame.

window.open()

window.location.href

JavaScript Timing Events :

With JavaScript, it is possible to execute some code after a specified time-interval.

setTimeout()

clearTimeout()

setInterval()

clearInterval()

Exercises :
  1. Which one is the root element in the DOM ?
  2. What are the attributes of the form tag ?
  3. Write the code for getting how many div nodes are there in the given structure ?
  4. Write the code to delete all the child node of as below structure
    <div>Statement 1
          <div>Statement 2</div>
             <div>Statement 3
                   <span>Statement 4</span>
             </div>
    </div>
    <div>
       Statement 5.
    </div>
  5. Write syntax for link: "http://google.com" in new window and new tab.
After editing Click here:
Output: