JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<button id="button1" style="z-index: 2000;" class="clear">Clear</button>
</body>
JavaScript
$(document).ready(function () {
$(this).mousedown(function (e) {
if (!$(e.target).is("#button1")) {
$x = e.pageX;
$y = e.pageY;
$div = "<div class='theDiv' style='width: 250px; height: 150px; background-color:#e7e7e7; position: absolute; top:" + $y + "px; left:" + $x + "px;'>Hey</div>";
$("body").prepend($div);
}
});
$("#button1").click(function () {
$(".theDiv").remove();
});
})