本文实例讲述了jquery图形密码实现方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery.min.js"> <script type="text/javascript">
$(document).ready(function() {
    var n=0,y=['4','8','12','13','14','15','16'];
    for(var i=1;i<=16;i++){
        var Box='<span id="box_'+i+'" class="box" num="0"></span>';
        $('#lower').append(Box);
        if(i<=4){
            $('#box_'+i+'').animate({left:100*i-100+"px"}, 0)
                           .show(0).delay(i*400-400).animate({width:"90px",height:"90px",top:"300px"}, 800).attr("num",i);
        }else if(i<=8){
            $('#box_'+i+'').animate({left:100*i-500+"px"}, 0)
                           .show(0).delay(i*400-400).animate({width:"90px",height:"90px",top:"200px"}, 800).attr("num",i);
        }else if(i<=12){
            $('#box_'+i+'').animate({left:100*i-900+"px"}, 0)
                           .show(0).delay(i*400-400).animate({width:"90px",height:"90px",top:"100px"}, 800).attr("num",i);
        }else{
            $('#box_'+i+'').animate({left:100*i-1300+"px"}, 0)
                           .show(0).delay(i*400-400).animate({width:"90px",height:"90px",top:"0px"}, 800).attr("num",i);
        }
    };
    $('#lower span').bind("click",function(){
        $(this).addClass("select");
        var code=$(this).attr("num");
        for (var j=0; j<y.length; j++){
            if(code==y[j]){
                y = jQuery.grep(y, function(n, i){
                  return (n != code);
                });
                n=n+1;
            }else{
                n=n+0;
            }
        };
        if($('.select').length==7){
            if(n==7){
                $('#lower').empty().append('<a href="#"></a>');
                $('#lower a').fadeIn(800);
            }else{
                $('#page').delay(1000).append('<div id="tips"><p>密码错了,重来吧!</p></div>');
                $('#tips').slideDown(500).delay(2000).slideUp(500);
                $('#lower span').removeClass("select");
                n=0;
                y=['4','8','12','13','14','15','16'];
            }
        }  
    });
});
</script>

希望本文所述对大家的jquery程序设计有所帮助。

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com