Dear Mates, Please click the ads to support us.
Tutorial

How to remove the div or element using jquery

Kailash Singh Dec 19, 2022 2012 Views
Kailash Singh

How to remove the div or element using jquery Share

Published Dec 19, 2022 by Kailash Singh 0 Comments 2012 Views

In this tutorail, you will be learning how to remove the div tag or html element using jQuery.

We will be using jQuery remove() method to remove that exact html element using jQuery as given below example:

 

Source Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>How to remove the div or element using jquery - Elevenstech Web Tutorials</title>
</head>
<body>

    <div id="myDivSection">
        <h4>Hello Guys, You are going to remove this div</h4>
        <p>This is a paragraph</p>
    </div>

    <button type="button" id="myButton">Click to remove</button>
   
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function () {

            $("#myButton").click(function() {  

                $("#myDivSection").remove();  

            });

        });
    </script>
    
</body>
</html>

 

Comments 0