top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to remove set of matched elements in jQuery?

0 votes
22 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 Google+ Share Button LinkedIn Share Button Multiple Social 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...