标签:
<span style="color:#006600;"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title> 抽奖 </title> | |
<meta name="Generator" content="EditPlus"> | |
<meta name="Author" content=""> | |
<meta name="Keywords" content=""> | |
<meta name="Description" content=""> | |
<style> | |
p{color:#ff3366;font:bolder 30px 微软雅黑;text-align:center;} | |
.select{width:100px;height:60px;border:#ff66ff solid 1px;background-color:#ffffff;float:left;margin:10px;font:bolder 22px 黑体;text-align:center;line-height:60px;} | |
.row1{width:600px;height:100px;margin-right:2px;float:left;} | |
.row2{width:600px;height:100px;float:left;clear:left;} | |
.row3{width:600px;height:100px;margin-left:2px;float:left;clear:left;} | |
#button{width:228px;background-color:#ff3366;font:bolder 22px 黑体;line-height:60px;cursor:pointer;border:#ff66ff solid 0;} | |
#main{margin:100px 250px} | |
</style> | |
<script type="text/javascript" language="javascript"> | |
var speed=800; | |
var id=0; | |
var on=0; | |
function select(){ | |
var num=Math.round(Math.random()*1000); | |
if(num>998){ | |
alert("恭喜你获得特等大奖!\n【豪华别墅一套】");//概率:1/1000 | |
}else if(num>990){ | |
alert("恭喜你获得一等奖!\n【法拉利跑车一辆】");//概率:1/100 | |
}else if(num>900){ | |
alert("恭喜你获得二等奖!\n【欧洲十国游】");//概率:10/100 | |
}else if(num>800){ | |
alert("恭喜你获得三等奖!\n【ipone5一部】");//概率:20/100 | |
}else if(num>600){ | |
alert("恭喜你获得幸运奖!\n【嘉年华礼包一份】");//概率:40/100 | |
}else if(num>500){ | |
alert("恭喜你获得参与奖!\n【活动公仔一对】");//概率:50/100 | |
}else{alert("抱歉,你没有获得任何奖品!\n 再接再厉!");}//概率:50/100 | |
} | |
function sta(){ | |
if(on==0){ | |
if(id>0) | |
id--; | |
on=1; | |
start(); | |
}else{ | |
select(); | |
document.getElementById("button").innerHTML="点击抽奖"; | |
on=0; | |
} | |
} | |
function start(){ | |
if(on==1){ | |
if(id>9){ | |
id=id%10; | |
} | |
id++; | |
var currentdiv=document.getElementById(id); | |
document.getElementById("button").innerHTML="暂停"; | |
if(id<11){ | |
changeColor(currentdiv,"#ff3366"); | |
var t=setTimeout("test(id)",speed); | |
} | |
} | |
} | |
function changeColor(obj,color){ | |
obj.style.backgroundColor=color; | |
obj.style.fontSize="18px"; | |
obj.innerHTML="抽奖中.."; | |
} | |
function test(id){ | |
if(on==1){ | |
var button=document.getElementById(id); | |
changeColor(button,"#ffffff"); | |
button.innerHTML=id; | |
speed-=30; | |
if(speed<100){speed=100;} | |
start(); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<p>豪华别墅、法拉利跑车、欧洲十国游、ipone5等你来拿!<p> | |
<p>千万不要错过千年一遇的机会哦!<p> | |
<div id="main" class=""> | |
<div id="" class="row1"> | |
<div id="1" class="select">1</div> | |
<div id="2" class="select">2</div> | |
<div id="3" class="select">3</div> | |
<div id="4" class="select">4</div> | |
</div> | |
<div id="" class="row2"> | |
<div id="10" class="select">10</div> | |
<div id="button" class="select" onClick="sta()">点击抽奖</div> | |
<div id="5" class="select">5</div> | |
</div> | |
<div id="" class="row3"> | |
<div id="9" class="select">9</div> | |
<div id="8" class="select">8</div> | |
<div id="7" class="select">7</div> | |
<div id="6" class="select">6</div> | |
</div> | |
</div> | |
</body> | |
</html></span> |
标签:
原文地址:http://www.cnblogs.com/xiaodi914/p/4241015.html