Remove Each Matching Element .detach()

.detach([selector])

e.g. $("div").detach(".className")

.detach() will remove each element in the matched set and everything inside it.

.detach() is similar to .remove() will remove the element itself and its inner contnet, the only difference is that .detach() will keep jQuery data, such as events, associated with the removed elements.
Example 1: $("div").detach() will remove all <div> and their content.
Before
<div>
  <b>A</b>
</div>

<div>B</div>

<b>C</b>
After
 // removed <div><b>A</b></div> 

 // removed <div>B</div> 

<b>C</b>
Example 2: $("div").detach(".a") will remove all <div> with class='a' and their content.
Before
<div class="a">A</div>
<div>B</div>
After
 // removed <div class='a'>A</div> 
<div>B</div>
jQuery manipulation removing .detach()