$(document).ready(function () {
var p;
$("#detach").click(function () {
p = $("p").detach();
});
$("#attach").click(function () {
$("#targetDiv").append(p);
});
});
<html>
<head>
<title>detach</title>
</head>
<body>
<div id="targetDiv">
<p>This is 99codingexample.</p>
</div><br />
<input type="button" id="detach" value="Detach"/>
<input type="button" id="attach" value="Attach"/>
<input type="button" id="reset" value="Reset" onclick="location.reload()" />
</body>
</html>