Web.QHMIT
.com
Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
Run
<!DOCTYPE html> <title>My Example</title> <style> .box { background: orange; color: white; padding: 10px; } p { border: 1px dotted white; padding: 5px; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> $( function() { $( ".box p" ).click( function() { $( this ).detach(); }); }); </script> <p>Click a paragraph to detach it.</p> <div class="box"> <p>Main content.</p> <p>More content.</p> <p>Extra content.</p> </div> <p>The <code>.detach()</code> method is the same as <code>.remove()</code>, except that <code>.detach()</code> keeps all jQuery data associated with the removed elements. This can be useful if you need to insert the removed elements back into the DOM at a later time.</p>
Preview