I am trying to create a scenario where something on the page is clicked, then a h1 will appear in a random place. However, I would then like that first h1 to stay in place and another appear in another random place and so on after each click. If the button was clicked continuously then the page will fill up with the same h1 tag. Almost like when Windows has a melt and loads of the same pop ups "pop up" and you have to click to get rid of them. I've tried doing this myself from searching other questions, but the code gets quite complicated when trying to adapt it from other users questions and answers.
So far I have managed to get the h1 tag to move randomly around the page. I've also managed to get it to clone the h1. However at the moment it all stays in one long list (apart from the original instance), instead of stopping in place with each instance as I'd like.
I've seen many different versions of creating the random part, so I'm entirely open to any ideas or completely new code to get this working.
{ $(document).ready(function () { $(".btn").click(function () { var bodyWidth = document.body.clientWidth; var bodyHeight = document.body.clientHeight; var randPosX = Math.floor(Math.random() * bodyWidth); var randPosY = Math.floor(Math.random() * bodyHeight); $(".words").clone().appendTo("body"); $(".words").css("left", randPosX); $(".words").css("top", randPosY); }); }); } body { margin: 0; padding: 0; background-color: white; } .words { position: relative; color: black; font-size: 20px; left: 0; top: 0; } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <body> <h1 class="words"> Hello! </h1> <button class="btn" type="button">Click Me!</button> </body>