Last active
November 10, 2021 20:38
-
-
Save ryosuzuki/4522409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
button { | |
color: red; | |
} | |
p { | |
font-size: 1.2em; | |
color: red; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(function(){ | |
max = 50; | |
bingo = new Array(); | |
for(i = 1; i <= max; i++) { | |
bingo.push(i); | |
} | |
status = 0; | |
$("button").click(function(){ | |
if(status == 0) { | |
status = 1; | |
$("button").text("Stop"); | |
roulette = setInterval(function(){ | |
random = Math.floor(Math.random() * bingo.length); | |
number = bingo[random]; | |
$("#number").text(number); | |
}, 100); | |
} else { | |
status = 0; | |
$("button").text("Start"); | |
clearInterval(roulette); | |
random = Math.floor(Math.random() * bingo.length); | |
result = bingo[random]; | |
bingo.splice(random, 1); | |
$("#number").text(result); | |
$("#result").append(result + ", "); | |
} | |
}); | |
}); | |
</script> | |
<button>Start</button> | |
<div id="number"> | |
</div> | |
<h1>Result</h1> | |
<div id="result"> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment