I'd like to have a page with a button and when I click the button the text should be shown. the text is taken from different arrays randomly with Javascript. Everything works in my project except one thing: On the first load of the page I see no text just the button. How do I make so that one of the arrays is randomly chosen and displayed on the fist page load (without click on the button)
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
var quotes = [{
text: " <br> 1 <br><br> 2 <br><br> 3 ",
}, {
text: " <br> 4 <br><br> 5 <br><br> 6 ",
}, {
text: " <br> 7 <br><br> 8 <br><br> 9 ",
}, ];
var quote1 = quotes[Math.floor(Math.random() * quotes.length)];
document.getElementById("quote1").innerHTML =
'<p><font size="7">' + quote1.text + '</font></p>';
}
</script>
</head>
<body>
<center>
<div id="quote1"></div>
<br>
<br>
<br>
<br>
<br>
<center>
<a href="#" onclick="myFunction()">Next</a>
</center>
</center>
</body>
</html>
Thank you!
myFunction().