Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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