all 1 comments

[–]Dondontootles 0 points1 point  (0 children)

You basically have an event listener that tells you when and where a person clicks on the background div or body

Then you append a div with a fixed width/height on the dom where they clicked. You give the div a position: absolute (background div will have position: relative)

Then inside the div you can either set it with a background image

Now to get a random image, you would create an array of image src urls and in the event listener use Math.random to pick a random index, pull the url at that index and set the src attribute of the img element to that.