<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>抽奖</title>
<style type="text/css">
*{margin:0;
padding: 0
}
.class1{
background-color: #047;
width: 400px;
height: 50px;
margin: 0 auto;
padding-top: 30px;
text-align: center;
font-size: 34;
font-weight: bold;
color: #f00;
}
.class2{
width: 220px;
height: 30px;
text-align: center;
font-weight: bold;
margin: 0 auto;
}
.class2 span{display: block;
float: left;
width: 80px;
height: 25px;
line-height: 25px;
background: #036;
border: 1px solid #eee;
border-radius: 7px;
margin-right: 20px;
color: #fff;
text-align: center;
font-size: 14px;
font-family: "微软雅黑";
cursor: pointer;
}
</style>
</head>
<body>
<div id="class1" >开始抽奖啦!</div>
<div>
<span id="ksan">开 始</span>
<span id="stop">停 止</span>
</div>
</body>
</html>
<script type="text/javascript">
var shuzu=['奖1','2','3','4','5'],t=null;
window.onload=function () {
var ksan=document.getElementById('ksan');
var stop=document.getElementById('stop');
ksan.onclik=kaishi;
stop.onclik=jieshu; }
function kaishi(){
var ksan=document.getElementById('ksan');
var title=document.getElementById('class1');
clearInterval(t);
t=setInterval(function(){
var redom=Math.floor(Math.random()*shuzu.length);
title.innerHtml=shuzu[redom];
},50);
}
function jieshu(){
clearInterval(t);
}
</script>
jddod