温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

jquery常用代码--(二)

发布时间:2020-07-06 19:53:05 来源:网络 阅读:260 作者:sunny叶雨竹 栏目:web开发

3.进度条  

    1.横向进度条带固定百分比      

        function SetProgress(progress) {                

                if (progress) {     

                        $(".inner").css("width", String(progress) + "%"); //控制#loading div宽度                                        $(".inner").html(String(progress) + "%"); //显示百分比              

                 }       

         }       

         var i = 0;       

         function doProgress()  { 

                    if (i >80)  { return;  } 

                    if (i <= 80) { 

                                         setTimeout("doProgress()", 50);        

                                            SetProgress(i);       

                                             i++; }          

                        }      

                   $(document).ready(function() {  doProgress();        

            });

            2.横向进度条的书写,仅仅色块宽度不同        

          function doProgress(classname,color,widthmax) {

                      $('.'+classname).animate({width:widthmax,background:color},500);        

            }        

          $(function(){ 

                    doProgress('list_blue','#56A8E7',30); 

                    doProgress('list_red','#F1705C',40); 

                    doProgress('list_orange','#FDAA29',50);

                    doProgress('list_green','#8FC842',20);         

          });



4. Banner切换


jquery常用代码--(二)


/*左边点击事件,调用go函数*/

$(".pre").click(function(){

        if(curr>=max-1){            

               return false;

        }

        else if(curr==max-2){                       

                $(".pre").removeClass("cur");        

                go(curr+1);        

                $('.text_banner .text_ban').addClass('display_none');        

                $('.text_banner .text_ban').eq(curr+1).removeClass('display_none');                            

                 curr++;                               

                 $(".next").addClass("cur");                        

         }              

        else {        

             $(".pre").addClass("cur");       

             go(curr+1);      

             $('.text_banner .text_ban').addClass('display_none');       

             $('.text_banner .text_ban').eq(curr+1).removeClass('display_none');                     

             curr++;      

             $(".next").addClass("cur"); 

        }

});

/*右边点击事件,调用 go函数*/

$(".next").click(function(){     

      if(curr<=0) {

                return false;                

      }        

    else if(curr==1) {

            $(".next").removeClass("cur");

            go(curr-1);

            $('.text_banner .text_ban').addClass('display_none'); 

            $('.text_banner .text_ban').eq(curr-1).removeClass('display_none');                          

            curr--;                         

             $(".pre").addClass("cur");       

        }       

    else {

                $(".next").addClass("cur");

                go(curr-1);$('.text_banner .text_ban').addClass('display_none'); 

                $('.text_banner .text_ban').eq(curr-1).removeClass('display_none');

                curr--;$(".pre").addClass("cur");       

            }

});        

最后写前面所调用go函数

    function go(index){ 

             $(".banner_change_box div ul").animate({left:-(wid*index)});

    };




向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI