Table of Contents
Back Button
Back to Chapter
Control Statements
No items found.
Function & Events
No items found.
Array and its Types
No items found.
OOP : Object Oriented Programming
No items found.
Javascript Standards
No items found.
HTML DOM
No items found.
Javascript : Advanced 1
No items found.
Javascript : Advanced 2
No items found.
Additional JavaScript
No items found.

Introduction To DOM

Introduction

DOM refers to the Document Object Modal. Every time Browser Loads Any Webpage it creates the DOM of that Page.

Or You can simply understand that when any page is loaded in the browser it generates a structure of the website, which element comes under which Element.

You can Understand this by looking to The Flowchart:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/736640ca-3411-4617-8676-d4cd215c0b54/pic_htmltree.gif

What you can do with DOM?

  • You can add new HTML elements and attributes
  • You can change all the HTML elements and attributes in the page
  • You can change all the CSS styles in the page
  • You can remove existing HTML elements and attributes
  • You can create new HTML events in the page

DOM Methods & Properties

DOM Methods and Properties are used to perform actions in DOM.

  1. DOM methods are actions you can perform (on HTML Elements like adding or removing an HTML Element).
  2. Example:
  3. getElementById("//Id") ⇒ The Best way to select an HTML element is to use the id of the element with this Method.
  4. DOM properties are values (of HTML Elements) that you can set or change.

Example:

innerHTML ⇒ It is used to get and replace the content of an element.

For Example:

Here,

document is the Javascript Browser Object that means we are referring to the document of the current page.

And in the current page we are using DOM Method getElementById("myParagraph") i.e. We are Selecting the Element with Id ⇒ myParagraph

innerHTML is the DOM Property that means everything that is written inside the Selected Element

i.e. Here We have Selected the Element with Id ⇒ myParagraph and we are getting the Text written inside the Element.

Ask queries
Contact Us on Whatsapp
Hi, How Can We Help You?