How to remove an element from DOM using jQuery?

jQueryWeb DevelopmentFront End Technology

The empty() method removes all child nodes from the set of matched elements whereas the method remove() method removes all matched elements from the DOM.

To remove an element, use the remove() method.


You can try to run the following code to learn how to remove an element from DOM using jQuery:

Live Demo

      <title>jQuery remove() method</title>
      <script src = ""></script>
         $(document).ready(function() {
            $("div").click(function () {
               $(this).remove( );
         .div {
             border:2px solid #666;
      <p>Click on any square below:</p>
      <span id = "result"> </span>
      <div class = "div" style = "background-color:blue;"></div>
      <div class = "div" style = "background-color:green;"></div>
      <div class = "div" style = "background-color:red;"></div>
Published on 17-Dec-2017 23:06:31