JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input type="submit">
</form>
JavaScript
var allWords = [
'Hello',
'No',
'Hi',
'Banana',
'Apple'
];
function getRandomWord(words) {
var randomIndex = Math.floor(Math.random() * words.length);
return words[randomIndex];
}
document.querySelector("form").addEventListener("submit", function(e) {
e.preventDefault();
var fullWidth = window.innerWidth;
var fullHeight = window.innerHeight;
var elem = document.createElement("div");
elem.textContent = getRandomWord(allWords);
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);
});