I have a question related to jQuery .remove()
method. Consider this code:
var x;
$("#btn1").click(function() {
x = $("p").remove();
});
$("#btn2").click(function() {
$("body").prepend(x);
});
If the code is checked on click on the button2, the paragraph element is restored.
I heard that remove()
and detach()
methods are different. How can they be different when remove()
itself keeps all jQuery data?
javascript:
keyword. – Philipp