I know how to randomize numbers like 1 to 100 but not certain numbers. Like I only want like 1, 15 , etc. I was looking around and its too confusing. Is there a easier way? Thank you!
function getRandom() {
return Math.random()1, 15, 30, 45;
}
ALL THE CODE ( It has an animation and I want a random (certain) number to appear in the box after the animation
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<!DOCTYPE html>
<html>
<head></head>
<title>The Wheel!</title>
<body bgcolor="orange">
<head>
<style>
.wheel {
width: 200px;
height: 100px;
left: 600px;
top: 300px;
background: green;
position: relative;
}
.animated-wheel {
-webkit-animation: myfirst4s 2;
-webkit-animation-direction: alternate;
animation: myfirst 4s 2;
animation-direction: alternate;
}
@-webkit-keyframes myfirst {
0% {background: green; left: 600px; top: 300px;}
33% {background: black; left: 600px; top: 0px;}
66% {background: red; left: 600px; top: 650px;}
100% {background: black; left: 600px; top: 0px;}
}
@keyframes myfirst {
0% {background: green; left: 600px; top: 300px;}
33% {background: green; left: 600px; top: 300px;}
66% {background: black; left: 600px; top: 0px;}
100% {background: red; left: 600px; top: 650px;}
}
</style>
</head>
<div class="wheel"></div>
<button onclick="startbtn()">Start</button>
<button onclick="refresh()">Reset</button>
<button onclick="getRandom()">Number</button>
<p id="getRandom()"></p>
<script>
startbtn = function() {
$('.wheel').addClass('animated-wheel');
}
function refresh() {
location.reload();
};
function getRandom() {
var values = [1, 15, 30, 45];
return values[Math.floor(Math.random() * values.length)];
}
</script>
</body>
</html>