I recently started a new project, so at the moment it is quite simple code. I think there is probably just and error or something I am unaware of that is causing an issue. To a more experienced programmer, this should be an easy fix. My HTML and JavaScript is
var quotecount = 3;
function show() {
var rand = Math.floor((Math.random() * quotecount) + 1);
if (rand == 1) {
document.getElementById("disp").innerHTML = "Quote 1";
document.getElementById("quotenum").innerHTML = "This is quote 1 out of " + quotecount;
}
if (rand == 2) {
document.getElementById("disp").innerHTML = "Quote 2";
document.getElementById("quotenum").innerHTML = "This is quote 2 out of " + quotecount;
}
if (rand == 3) {
document.getElementById("disp").innerHTML = "Quote 3";
document.getElementById("quotenum").innerHTML = "This is quote 3 out of " + quotecount;
}
}
button {
background: #fff;
border: 1px solid #ccc;
padding: 5px 13px;
outline:none;
cursor:pointer;
}
button:hover {
background: #282828;
color: #fff;
}
<!DOCTYPE html>
<html>
<body>
<button id="quoteshow" onclick="show">Click me to show a quote!</button>
<p id="disp"></p>
<p id="quotenum"></p>
</body>
</html>
<script>tag and you should wait for DOM to load, actually call your function, remove the tickmark`and read console errors