Skip to content

Instantly share code, notes, and snippets.

@hyeonseok
Created April 18, 2014 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyeonseok/11020894 to your computer and use it in GitHub Desktop.
Save hyeonseok/11020894 to your computer and use it in GitHub Desktop.
Random number, at the end of event.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>추첨기</title>
<style>
html,
body {
height: 100%;
}
body {
background: linear-gradient(#0095DD, #00539F);
line-height: 1em;
}
p {
position: absolute;
top: 50%;
left: 0;
margin: -0.5em 0 0 0;
width: 100%;
color: #fff;
font-size: 20em;
margin: 0;
text-align: center;
}
</style>
</head>
<body onclick="start()">
<p id="number">Click</p>
<script>
var to = 226;
var count = 0;
function num() {
var el = document.getElementById('number');
el.innerHTML = Math.round((Math.random() * (to - 1)) + 1);
count++;
if (count > 120) {
return;
}
window.setTimeout(function () {
window.num();
}, 10);
}
function start() {
window.count = 0;
num();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment