top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to remove set of matched elements in jQuery?

0 votes
457 views
How to remove set of matched elements in jQuery?
posted Jul 18, 2017 by Saheb Pro

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

The .remove() method removes all matched elements from the DOM. Use .remove() when you want to remove the element itself, as well as everything inside it (its child elements). In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.

Example

<head>
  <meta charset="utf-8">
  <title>remove demo</title>
  <style>
  p {
    background: yellow;
    margin: 6px 0;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
  <p>Hello how are you?</p>
  Hello how are you?
  <p>Hello how are you?</p>
  <button>Remove Element</button>
  <script>
  $( "button" ).click(function() {
    $( "p" ).remove();
  });
  </script>
</body>

Preview

enter image description here

After Click on Remove Element Button

enter image description here

answer Jul 18, 2017 by Shyam Chakraborty
...