What is DOM?

Prodip Sarker
2 min readSep 22, 2020

In simple words, DOM is a document object model. When the browser parses an HTML file then javascript creates an object of this HTML file. That’s why we can easily access/change/modify it in this HTML file in real-time. The browser converts this HTML file to a document.

#Example

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>DOM Explore</h1>
</body>
</html>

Run this file and inspect this in our browser than the console tab type console.log(document). you can see the output of an object in this HTML file.

If you type console.log(document.body). you only see the body part of this document.

### How to access DOM element

There are many ways to access the DOM element. I show you one example of this.

### selector in Javascript

  1. getElementByID()
  2. getElementsByClassName()
  3. getElementsByName()
  4. getElementsByTagName
  5. querySelector()
  6. querySelectorAll()

--

--

Prodip Sarker
Prodip Sarker

Written by Prodip Sarker

in a relationship with console.log()

No responses yet