JavaScript Code

How to remove paragraph using JavaScript?

Tutorials using JS

Problem Statement

remove paragraph element from the document using JavaScript


to remove a paragraph element from document using JavaScript, we can use remove() method on the element. get the paragraph element, and call remove() method


remove() method removes the calling element from the document


in the HTML, we have a Click me button and paragraph. when user clicks on the Click me button, we get the paragraph element by id myPara and remove it from the document using remove()

<!DOCTYPE html>
<h1>JavaScript Tutorial</h1>
<button id="myBtn">Click me</button>
<p id="myPara">This is a paragraph. Welcome to JavaScript tutorials.</p>

document.getElementById("myBtn").addEventListener("click", function() {
    //get the paragraph element
    const myPara = document.getElementById("myPara");
    //remove the paragraph


Copyright @2022