I am trying to use jQuery to move a form from one div to another onclick. Seems simple but it doesn’t seem to work… Here’s what I’ve got.
$(".btn").click(function() {
$("#div2").append("#frm");
$("#div1").remove();
});
<div id="div1">
<form id="frm"><input class="web" type="text"><span class="btn">go</form>
</div>
<div id="div2">
content
</div>
$("#div2").append("#frm")is appending the string"#frm"todiv2, not the the form element itself whoseidisfrm. Append$("#frm")instead to add the form element:DEMO.