so I was wandering how to make splash text that randomizes when you click it, because everywhere I go it doesn’t work, and I just simply cant find it anywhere.
<!DOCTYPE html>
<html>
<head>
<title>Random Text Selector</title>
</head>
<body>
<button onclick="myFunction()" id="select">Pick text</button>
<div class="main">
<p id="result"></p>
</div>
<footer class="footer">please help me fix this</footer>
<script>
function myFunction() {
var idArray = [];
idArray[0] = "hi";
idArray[1] = "hello";
idArray[2] = "SKhfvkhbSVHgjfg";
idArray[3] = "k";
idArray[4] = "c'ya";
var randomParagraph = Math.floor(Math.random() * 5);
document.getElementById("result").innerHTML = idArray[randomParagraph];
}
</script>
</body>
</html>
because this doesn’t work and its not when I click the text anyway.(this is a combination of chat gpt and the only thing I found on the internet)
New contributor
Nathan Hall is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.