DOM manipulation in JavaScript

DOM manipulation in JavaScript

Hey readers, in this article we will be discussing DOM manipulation in JavaScript in a step-wise, efficient manner. If you are a beginner and want to learn JavaScript then do check out the course on Codedamn. DOM manipulation is an important factor while creating a web application using HTML and JavaScript. In this article, we will be learning about what is DOM (Document Object Model) and how to use it along with its features and functions using JavaScript and HTML. If you already know JavaScript then keep reading.

The Document Object Model (DOM) in HTML 

  • The browser produces a Document Object Model of a web page when it is loaded.
  • The HTML DOM model is built as a hierarchy of Objects.
  • JavaScript now has all the power it needs to build dynamic HTML thanks to the object model.
  • JavaScript has the ability to alter all HTML components on a page.
  • JavaScript has the ability to alter all of the HTML attributes on a page.
  • JavaScript has the ability to change all of the page’s CSS styles.
  • Existing HTML elements and attributes can be removed using JavaScript.
  • JavaScript has the ability to create new HTML elements and properties.
  • All HTML events on the page can be reacted to by JavaScript.
  • JavaScript has the ability to add new HTML events to a page.

What exactly is the DOM?

The Document Object Model (DOM) is a W3C (World Wide Web Consortium) standard.

The DOM establishes a standard for document access:

“The W3C Document Object Model (DOM) is a platform- and language-independent interface that enables programs and scripts to dynamically access and edit a document’s content, structure, and style.”

The W3C DOM standard is divided into three sections:

The Core Document Object Model (DOM) is a common model for all document formats.

The XML Document Object Model (DOM) is a standard model for XML documents.

HTML DOM (Document Object Model) is a standard model for HTML documents.

What is the HTML Document Object Model (DOM)?

The HTML DOM is a programming interface and standard object model for HTML. It specifies:

The HTML element has objects within a function.

All HTML elements have properties.

All HTML components can be accessed using the following techniques.

All HTML elements have their own set of events.

In other words, the HTML DOM is a set of rules for getting, changing, adding, and removing HTML elements.

createElement() – creates a new element while manipulating elements.

appendChild() – adds a node to the list of child nodes of a parent node.

textContent -Get and set the text content of a node with textContent.

innerHTML – retrieve and set an element’s HTML content.

innerHTML vs. createElement- Explain the differences between innerHTML and createElement in terms of creating new elements.

DocumentFragment- Learn how to assemble DOM nodes and insert them into the active DOM tree with DocumentFragment.

insertBefore() – inserts a new node as a child node of a specified parent node before an existing node.

insertAfter() is a helper method that inserts a new node as a child node of a specified parent node after an existing node.

append() – adds a node to the end of a parent node’s final child node.

prepend() – inserts a node before a parent node’s first child node.

insertAdjacentHTML() – parses a text as HTML and inserts the generated nodes at a given point in the page.


Child() – replaces an existing child element with a new one.

cloneNode()- Clone an element and all of its descendants with cloneNode().

removeChild() – removes a node’s child items.


This was about DOM manipulation in JavaSript using HTML, if you want to learn more about javascript, do check out the article and course on Codedamn of javascript along with the course. Hope you liked this, if you have any queries or suggestions do let us know in the comments. 

If you are interested in learning JavaScript, do check out courses on codedamn with an in-built environment playground to learn and practice code. Join the community of codedamn and do check out other articles related to programming and development on codedamn and subscribe to our newsletter to never miss out on our new programs and updates.

If you have any queries or feedback do let us know in the comment section.

Become The Best JavaScript Developer 🚀
Codedamn is the best place to become a proficient developer. Get access to hunderes of practice JavaScript courses, labs, and become employable full-stack JavaScript web developer.

Free money-back guarantee

Unlimited access to all platform courses

100's of practice projects included

ChatGPT Based Instant AI Help (Jarvis)

Structured Full-Stack Web Developer Roadmap To Get A Job

Exclusive community for events, workshops

Start Learning

Sharing is caring

Did you like what Vishnupriya wrote? Thank them for their work by sharing it on social media.