zoukankan      html  css  js  c++  java
  • 抽奖转盘(jqueryrotate.js)

    jqueryrotate.js抽奖转盘,使用方便,兼容各浏览器,效果如下图

    <!DOCTYPE>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>转盘抽奖</title>
    <script src="js/jquery-1.11.0.min.js"></script>
    <script src="js/Rotate.js"></script>
    <style>
    *{padding:0; margin:0;}
    .lotteryMain{ width:100%; padding:20px 0; }
    .lotteryBg{ width:520px; height:520px; margin:0 auto; background:url(images/lotteryBg.jpg) no-repeat; position:relative; overflow:hidden;}
    #run{ width:153px; height:214px; position:absolute; left:50%; top:50%;  margin-left:-76px; margin-top:-107px; z-index:1; transform:rotate(0deg); -ms-transform:rotate(0deg); }
    #btn_run{ width:125px; height:125px; background:url(images/btn_start.png) no-repeat; border:none; outline:none; position:absolute; left:50%; top:50%; margin-left:-62px; margin-top:-62px; z-index:2;cursor:pointer;}
    </style>
    </head>
    
    <body>
    <section class="lotteryMain">
        <div class="lotteryBg">
            <img id="run" src="images/start.png" />
            <input id="btn_run" type="button" value="" />
        </div>
        <div id="results">
        
        </div>
    </section>  
    <script>
    $(function(){ 
         $("#btn_run").click(function(){
            $("#btn_run").attr('disabled',true).css("cursor","default"); 
            lottery(); 
        });
    }); 
    function lottery(){ 
        $.ajax({ 
            type: 'get', 
            url: 'json2.js', 
            dataType: 'json', 
            cache: false, 
            error: function(){return false;}, 
            success:function(obj){
                    $("#run").rotate({ 
                        duration:3000, //转动时间 
                        angle: 0, //默认角度
                        animateTo:360*6+obj.rotate, //转动角度 
                        easing: $.easing.easeOutSine, 
                        callback: function(){ 
                            alert(obj.results); 
                        $("#btn_run").attr('disabled',false).css("cursor","pointer"); 
                        } 
                    });
            } 
        }); 
    };
        
    </script>  
    </body>
    </html>
    View Code

    json.js里是个json对象,模拟服务器返回的数据,{"isHasChance":"true","rotate":240,"results":"iphone 5s!!"}

    demo下载(放在IIS上运行)

  • 相关阅读:
    Linux (x86) Exploit 开发系列教程之三(Off-By-One 漏洞 (基于栈))
    Linux (x86) Exploit 开发系列教程之二(整数溢出)
    Linux (x86) Exploit 开发系列教程之一(典型的基于堆栈的缓冲区溢出)
    Linux (x86) Exploit 开发系列教程之四(使用return-to-libc绕过NX bit)
    xss level11
    f.select
    jquery.backstretch
    linux目录或文件权限
    pradino 命令
    Padrino 博客开发示例
  • 原文地址:https://www.cnblogs.com/xiaomou2014/p/4063905.html
Copyright © 2011-2022 走看看