天天看点

jQuery幸运大转盘

JQuery幸运大转盘_jQuery+PHP抽奖程序的简单实现

jQuery幸运大转盘

在线实例

下载

完整代码

Js代码   

jQuery幸运大转盘
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3.     <head>  
  4.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  5.         <title>jQuery幸运大转盘_jQuery+PHP抽奖程序(上)</title>  
  6.         <style type="text/css">  
  7.             .demo{ position:relative;width:417px;}  
  8.             #disk{width:417px; height:417px; background:url(/api/jq/5733e347040d9/images/disk.jpg) no-repeat;}  
  9.             #start{width:163px; height:320px; position:absolute; top:46px; left:130px;}  
  10.             #start img{cursor:pointer}  
  11.         </style>  
  12.     </head>  
  13.     <body>  
  14.         <div class="container">  
  15.             <div class="demo">  
  16.                 <div id="disk"></div>  
  17.                 <div id="start"><img src="/api/jq/5733e347040d9/images/start.png" id="startbtn" alt="转盘开启"/></div>  
  18.             </div>  
  19.         </div>  
  20.         <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.7.2/jquery.min.js"></script>  
  21.         <script type="text/javascript" src="/api/jq/5733e347040d9/jQueryRotate.2.2.js"></script>  
  22.         <script type="text/javascript" src="/api/jq/5733e347040d9/jquery.easing.min.js"></script>  
  23.         <script type="text/javascript">  
  24.             $(function() {  
  25.                 $("#startbtn").rotate({  
  26.                     bind: {  
  27.                         click: function() {  
  28.                             var random = Math.floor(Math.random() * 360); //生成随机数  
  29.                             $(this).rotate({  
  30.                                 duration: 3000, //转动时间间隔(速度单位ms)  
  31.                                 angle: 0, //指针开始角度  
  32.                                 animateTo: 3600 + random, //转动角度,当转动角度到达3600+random度时停止转动。  
  33.                                 easing: $.easing.easeOutSine, //easing动画效果  
  34.                                 callback: function() {  //回调函数  
  35.                                     alert('恭喜您,中奖了!');  
  36.                                 }  
  37.                             });  
  38.                         }  
  39.                     }  
  40.                 });  
  41.             });  
  42.         </script>  
  43.     </body>  
  44. </html>