jquery 方块转盘 得 ###jiang####品
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery特效</title>
<style type="text/css">
*{padding:0px;margin:0px;}
body{font-size:12px;}
ul,li{ list-style:none;}
.choudiv{width:600px;margin:100px auto; position:relative;}
.choudiv .zblock{position:absolute;width:80px;height:80px; background:#09C; text-align:center;line-height:80px;}
.choudiv .li1{left:0px;top:0px;}
.choudiv .li2{left:80px;top:0px;}
.choudiv .li3{left:160px;top:0px;}
.choudiv .li4{left:240px;top:0px;}
.choudiv .li5{left:320px;top:0px;}
.choudiv .li6{left:320px;top:80px;}
.choudiv .li7{left:320px;top:160px;}
.choudiv .li8{left:240px;top:160px;}
.choudiv .li9{left:160px;top:160px;}
.choudiv .li10{left:80px;top:160px;}
.choudiv .li11{left:0px;top:160px;}
.choudiv .li12{left:0px;top:80px;}
.choudiv .zblock1{width:240px;height:80px; cursor:pointer;background:#f00; position:absolute;left:80px;top:80px; text-align:center;line-height:80px;}
.choudiv .sel{ background:#ff0;}
</style>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
function srandom(min1,max1){
return Math.floor(min1+Math.random()*(max1-min1));
}
$(".zblock1").live("click",function(){
if(!$(this).hasClass("unuse")){
$(this).addClass("unuse");
var i=0;
//var num=parseInt(30+Math.random()*20); //这个需要通过AJAX由后台程序给出
var time=50;
var j=srandom(1,5); //转的圈数
var leave=7; //停下来的数字
var oli=$("#outer").find("li");
var timer=setInterval(function(){
oli.css("opacity","1");
if(j>0){
if(i==12){
i=0;
j--;
$(".sel").removeClass("sel");
oli.eq(i).addClass("sel");
}else{
$(".sel").removeClass("sel");
oli.eq(i).addClass("sel");
i++;
}
}else{
if(i==leave){
clearInterval(timer);
$(".sel").removeClass("sel");
oli.eq(i).addClass("sel");
alert("抽中了"+i+"号");
$(".zblock1").removeClass("unuse");
}else{
$(".sel").removeClass("sel");
oli.eq(i).addClass("sel");
i++;
}
}
},50);
}else{
return false;
}
})
});
</script>
</head>
<body>
<div class="choudiv">
<ul id="outer">
<li class="zblock li1">0</li>
<li class="zblock li2">1</li>
<li class="zblock li3">2</li>
<li class="zblock li4">3</li>
<li class="zblock li5">4</li>
<li class="zblock li6">5</li>
<li class="zblock li7">6</li>
<li class="zblock li8">7</li>
<li class="zblock li9">8</li>
<li class="zblock li10">9</li>
<li class="zblock li11">10</li>
<li class="zblock li12">11</li>
</ul>
<div class="zblock1">开始</div>
</div>
</body>
</html>