jQuery remove Method


jQuery remove Method : is used to remove the selected element from the DOM. It removes the selected element completely from the document object model. It will exist no longer if you remove the element.

Note : Empty method removes child elements and keeps the selector element while remove method removes the child elements including the selector itself.

Syntax

Syntax for remove method –

$(selector).remove();

jQuery remove Method Example

Below example shows the remove method try it –

jQuery remove() Method – Example

<script type="text/javascript">
         $(document).ready(function(){ 
              $( "#removeExample" ).on( "click", function(event) {             
                $("#removeMe").remove();               
              });
               
          });
</script>

Try it »

The above example will produce following output-

jQuery remove Method Example And Demo


Advertisements

Add Comment

📖 Read More