JSFiddle - React, Tailwind, and code Playground
by snover
HTML
<div id="box"></div>
<div class="foo">
<input type="button" id="append" value="Append box">
<input type="button" id="append2" value="Append box">
</div>
CSS
body {
height: 2000px;
}
.foo {
position: fixed;
top: 5px;
left: 5px;
z-index:5;
}
#box {
width: 200px;
height: 200px;
background: #faeade;
position: absolute;
}
JavaScript
function foo(detach) {
var box = $('#box');
detach && box.detach();
box.offset({left: 100, top: 200});
detach && $('body').append(box);
}
$('#append').click(function () { foo(); });
$('#append2').click(function () { foo(true); });