For my website, I am trying to make a button where every time a press a button a different quote comes up. I have made a separate document to make this. I am not very experienced at javascript, so please help. This is my HTML:
<button">Change Quote</button>
<p id="test"></p>
I am aiming to give each quote a number value from one to ten so its random. Also, when I click the button the p changes. Thanks.
EDIT: Is there any way to have it cycle through? For instance, once I get the first quote, can it go onto the second?
new JS:
var quotes = [
"I am Bob",
"I am smart",
"I am independent",
"I am bringing change",
];
document.getElementById("changeQuote").addEventListener("click", function() {
var q = quotes[ Math.floor( Math.random() * quotes.length ) ];
document.getElementById("test").innerHTML = q;
Thanks again.