Skip to content

Instantly share code, notes, and snippets.

@VOID001 VOID001/index.html
Created Sep 26, 2016

Embed
What would you like to do?
抽奖程序
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container text-center">
<h1>先锋网宣讲 抽奖</h1>
<div class="well" style="margin-top:20%">
<div id="number" style="margin-top:-5; font-size:96px">
000
</div>
<button id="toggle" class="btn btn-primary" style="font-size:50px;margin-top:20%" onclick="Shuffle()">
START
</button>
</div>
</div>
<script type="text/javascript">
var start = false;
var flag;
function Shuffle()
{
if(!start)
{
$("#toggle").html("STOP");
$("#toggle").removeClass("btn-primary");
$("#toggle").addClass("btn-danger");
flag = setInterval(spin, 100);
}
else
{
$("#toggle").html("START");
$("#toggle").removeClass("btn-danger");
$("#toggle").addClass("btn-primary");
clearInterval(flag);
}
start = !start
}
function spin()
{
$("#number").html(GetRandom(98));
}
function GetRandom(upperbound)
{
var rand = Math.random() * 10000 % upperbound + 1
return Math.floor(rand);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.