JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input type="button" value="Show">
</form>
JavaScript
document.querySelector("form").addEventListener("click", function(e) {
e.preventDefault();
var fullWidth = window.innerWidth;
var fullHeight = window.innerHeight;
var text = getRandomWord();
var elem = document.createElement("div");
elem.textContent = text;
elem.style.position = "absolute";
elem.style.left = Math.round(Math.random() * fullWidth) + "px";
elem.style.top = Math.round(Math.random() * fullHeight) + "px";
document.body.appendChild(elem);
});
function getRandomWord(){
var words = [
'Hello',
'No',
'Hi',
'Banana',
'Apple'
];
return words[Math.floor(Math.random() * words.length)];
}