DEV Community

Kavya S
Kavya S

Posted on

Javascript DOM Manipulation

What is DOM?

DOM stands for Document Object Model, an interface for web documents that represents their structure as a tree-like object. It allows dynamic manipulation of page content using languages like JavaScript.

What is DOM Manipulation

DOM manipulation refers to the process of programmatically modifying the content, structure, or style of a web page's DOM using scripting languages like JavaScript.
Developers can add, remove, or modify elements, attributes, and text within the DOM to create dynamic and interactive web applications.

Example

<p id="one"> Hello </p>

<script>

//select paragraph tag using 10

var para = document.getElementById("one")

console.log(para.textContent)

para.textContent="Bye"

/script>
Enter fullscreen mode Exit fullscreen mode

What is an Event and Event handlers ?

An event in JavaScript is an action or occurrence that happens within a web page, such as a user's interaction (clicking a button) or a page loading.

An event handler in JavaScript is a function that responds to an
event when it occurs. It listens for specific events and executes code to perform actions based on those events, creating interactive and dynamic web applications.

Top comments (0)