Introduction:

In this article we will explain how to use remove() method in jQuery or What is remove() method in jQuery or why remove() method in jQuery or how to remove the selected elements from the DOM with example.

Description:

The jQuery remove() method is used to remove the selected elements from the DOM. It removes the selected element itself, as well as everything inside it (including all content and html elements). This method also removes the data and the events of the selected elements.

Syntax:

$(selector).remove(selector)

Let’s see, Example of jQuery remove() method:

 <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Example of jQuery remove method</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $("p").remove();
            });
        });
    </script>
</head>
<body>
    <div>
        <button>Click here to remove() paragraph</button>
        <div style="width:500px">
            <p style="background-color:ghostwhite;">
                SQLTutorialsPoint.com
            </p>
            <div style="background-color:#d5d5d5; margin-top:10px;">
                SQL Tutorials Point provide Programming concept.
            </div>
        </div>
    </div>
</body>
</html>


 Let's check live example

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like