I'm new to JavaScript, so there was a useful forum on this topic. I only know basic HTML and CSS.
I want to create a button script when you click it, every time you click on it, you will get a different answer. I know that to create an original button that displays the text on the screen, but I do not know how to script it to give a random answer each time.
More specific: I take 20 different answers
Thank you.
In Javascript you generate a random number between 0 and 19
$ ("# mybutton"). Click (function () {var index = Math.floor (Math.random (* * 19); var random answer = all greetings [index]; // display response}); and use it for an array of 20 items
No comments:
Post a Comment