The Wayback Machine - https://web.archive.org/web/20240713043241/https://www.geeksforgeeks.org/jquery-remove-method/
Open In App

jQuery remove() Method

Last Updated : 10 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The remove() method in JQuery is used to remove all the selected elements including all the text. This method also remove data and all the events of the selected elements.

Syntax:

$(selector).remove()

Return Value: It will return all the data of the selected elements deleted.

Example 1:

Input: $("p").remove()
Output: Output will be all the elements of the paragraph get deleted.

Example 1: In this example, we are using jQuery remove method.

html




<!DOCTYPE html>
<html>
 
<head>
    <script src=
        //this is JQuery CDN directed from the JQuery website
    </script>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $("p").remove();
            });
        });
    </script>
</head>
 
<body>
    <div style="padding-left:220px;
                padding-top:100px;">
        <p style="font-size:35px;">
            Welcome to GFG!!!.
        </p>
        <button style="padding:15px;">
            Click ME
        </button>
    </div>
</body>
 
</html>


Output:

jquery-23

We can also find and remove elements using their class name with the help of JQuery remove() method.

Syntax:

$(".class_name").remove()

Return value: It will return all the portions deleted on the page with the class name.

Example 2:

Input: $(".geek").remove()
Output: Here "gfg!!!" get deleted.

Example 2: In this example, we are using jQuery remove() method.

html




<!DOCTYPE html>
<html>
 
<head>
    <script src=
        //this is JQuery CDN directed from the JQuery website
                </script>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $(".geeks").remove();
            });
        });
    </script>
</head>
 
<body>
    <div style="margin-left:180px; font-size:35px;
                padding-top:100px">
        <p class="geeks">
            Welcome to GFG!!!.
        </p>
        <p class="geeks">
            Hello, My class is geeks
        </p>
        <button>Click ME</button>
    </div>
</body>
 
</html>


Output:

jquery-24



Previous Article
Next Article

Similar Reads

How to remove close button from jQuery UI dialog using jQuery ?
In this article, we will learn how to remove the close button on the jQuery UI dialog using JavaScript, This can be achieved using the hide() method. jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. A dialog box is a temporary window. An application creates a dial
2 min read
jQuery callbacks.remove() Method
The jQuery callbacks.remove() method is used to remove a single callback or a collection of callbacks from a callback list. Syntax: callbacks.remove( callbacks ) Parameters: callbacks: This parameter specifies a function, or an array of functions, which are to be removed from the callback list. Return Value: This method returns the Callbacks object
2 min read
How to remove all attributes of an HTML element using jQuery ?
In this article, we will see how to remove all attributes of an HTML element using jQuery. To remove all attributes of elements, we use the removeAttributeNode() method and .removeAllAttributes(). Syntax: $.fn.removeAllAttributes = function() { return this.each(function() { $.each(this.attributes, function() { this.ownerElement.removeAttributeNode(
1 min read
How to remove all the options of a select box and then add one option and select it using JQuery ?
Given a select box with a fixed number of options, the task is to remove all the options and then add one option and immediately select that particular option using jQuery. There are two approaches that can be taken to achieve this: Approach 1: Using find(), remove(), end() and append() Methods: In the following example, a select box with some opti
3 min read
jQuery | Remove Elements
In jQuery, in order to remove element and content you can use anyone of the following two jQuery methods: Methods: remove() - It is used to remove the selected element (and its child elements). empty() - It is used to removes the child elements from the selected element. Example-1: Using the jQuery remove() Method. &lt;!DOCTYPE html&gt; &lt;html
1 min read
JQuery | Remove “disabled” attribute from an element
There is an Input Element which is disabled, the task is to enable it using JQuery. Here are a few examples discussed. To understand example first few methods to know. JQuery prop() method This method set/return properties and values of selected elements. If we use this method to return the property value, it will return the value of the FIRST sele
2 min read
How to remove table row from table using jQuery ?
The jQuery remove() method is used to remove a row from HTML table. jQuery remove() Method: This method removes the selected elements alongwith text and child nodes. This method also removes data and events of the selected elements. Syntax: $(selector).remove(selector) Parameters: It accepts single parameter selector which is optional. It specifies
2 min read
How to fadeOut and remove a div using jQuery ?
Given a div element. The task is to remove it with a fadeOut effect using JQuery. Here are a few methods discussed. First few methods to know. jQuery text() Method: This method sets/returns the text content of the selected elements. If this method is used to return content, it provides the text content of all matched elements (HTML tags will be rem
4 min read
How to remove options from select element using jQuery ?
The task is to remove the option elements from the select element using jQuery. Approach: Select the option from select which needs to remove.Use JQuery remove() method to remove the option from the HTML document. Example 1: This example removes the option of which val = 'val_1' using remove() method. C/C++ Code &lt;script src= &quot;https://ajax.g
2 min read
How to Add and Remove multiple classes in jQuery ?
Given an HTML element and the task is to add and remove multiple classes from it using JQuery. Approach: First select the element to which multiple classes will be added. Then use addClass() method to add multiple classes to the element and removeClass() method to remove multiple classes. Example 1: This example add two classes color and fontWeight
2 min read
three90RightbarBannerImg