<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>jquery圓形轉盤抽獎</title> <script src="js/jquery-1.8.2.min.js" type="text/javascript"></script> <script type="text/javascript" src="js/jQueryRotate.2.2.js"></script> <script type="text/javascript" src="js/jquery.easing.min.js"></script> <style type="text/css"> /*背景*/ #lottery { width: 450px; height: 450px; position: relative; background: url("images/disc-bg.gif") no-repeat scroll 0 0 transparent; z-index: 99991; margin: 0px auto; margin-top: 30px; } /*轉盤*/ #lottery .img { position: absolute; left: 49px; top: 49px; width: 352px; height: 352px; z-index: 99992; } /*指標*/ #lottery .arrow { width: 32px; height: 191px; position: absolute; left: 209px; top: 85px; background: url("images/arrow.png") no-repeat scroll 0 0 transparent; z-index: 99993; } /*抽獎按鈕*/ #lottery .lot-btn { width: 92px; height: 92px; display: block; position: absolute; cursor: pointer; left: 179px; top: 183px; overflow: hidden; background: url("images/buttons_01.png") no-repeat scroll 0 0 transparent; z-index: 99994; } </style></head><body> <div id="lottery"> <img src="images/disc-rotate.gif" class="img" /> <div class="arrow"></div> <div class="lot-btn" onclick="javascript:DZP(10,6);"></div> </div></body></html><script> //先轉n圈,選擇m第個 function DZP(n, m) { //停止動畫 $('.img').stopRotate(); //轉 $(".img").rotate({ angle: 0, //起始角度 animateTo: 360 * n + 26 + 52 * m, //結束的角度 duration: 2500, //轉動時間 callback: function () { //得到角度 var r = $('.img').getRotateAngle(); }, //回呼函數 easing: $.easing.stopRotare //定義運動的效果,需要引用jquery.easing.min.js的檔案 }); }</script>
源碼:http://download.csdn.net/detail/dhfekl/7106035