javascript - How do I display randomly an array without click on the button? -


i'd have page button , when click button text should shown. text taken different arrays randomly javascript. works in project except 1 thing: on first load of page see no text button. how make 1 of arrays randomly chosen , displayed on fist page load (without click on 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!

call on page load.

window.onload = function(){    myfunction(); } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -