<!DOCTYPE html>
<html>
<head>
<title>jQuery detach() method</title>
<script src="jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
var ele;
$(".detach").click(function(){
ele = $("#p2").detach();
});
$(".restore").click(function(){
$("p").append(ele);
});
});
</script>
</head>
<body>
<div>
<p>First paragraph start here...</p>
<p id="p2">Second paragraph start here...</p>
</div>
<button class="detach">Detach element</button>
<button class="restore">Restore element</button>
</body>
</html>