DO

DO

DOM


This blog is about the most important for the web that is DOM (Document Object Model). A Document object represents the HTML document that is displayed in that window. More simply, a document object represents the whole HTML document. When we run an HTML document on the web and the document is loaded in the browser it becomes a document object. 


The DOM views an HTML document as a tree of nodes and a node represents an HTML element. An HTML document called a root node contains a child node which is <html>. The <html> element contains two children which are <head> and <body>. Then <head> and <body> have their own children. You will betten understand from the following graph.


No alt text provided for this image

Here we can access these elements using JavaScript events. We can select a document object using JavaScript selector method like getElementById(), getElementByName(), getElementByTagName(), querySelector() and querySelectorAll() etc. 


We can also create the new elements using the createElement() method and style them. Moreover, we can addEventListerner() to listen for events on the page. 


DOM stands for Document Object Model and is a programming interface that allows us to create, change or remove elements from the document. We also have access to add events to these elements to make our web page more dynamic.

DOM in REACT


React Js creates a virtual dom in memory for every re-render. Virtual dom is not more than a copy of real dom. 


We can think of a virtual dom as a tree and we can think of every node as a component. If we change any state of the tree then it creates a new tree where the change component and child component creates. Here react has two dom representations and react compares these changes using diff algorithm.



To view or add a comment, sign in

More articles by Rasel Ahmad

  • CLOSURE IN JAVASCRIPT

    Closure in JavaScript In this blog, you can understand closure in javascript which is one of the important concepts in…

  • CSS POSITION

    CSS POSITION This blog is about the most confusing part of CSS for most beginner CSS learners. Basically, the CSS…

Insights from the community

Others also viewed

Explore topics