DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> jquery圖形密碼實現方法
jquery圖形密碼實現方法
編輯:JQuery特效代碼     

本文實例講述了jquery圖形密碼實現方法。分享給大家供大家參考。具體實現方法如下:

代碼如下:<script type="text/javascript" src="js/jquery.min.js"></script>
<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程序設計有所幫助。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved