首页 > 代码库 > 进度条【改进】

进度条【改进】

 

//进度条(function($) {  $.fn.progressBar = function(options) {    var opts = $.extend(true, {},    $.fn.progressBar.defaults, options);    return this.each(function() {        var $this = $(this);            var text = $this.text();            var index = text.lastIndexOf("%");            text = text.slice(0,index);            text = parseInt(text,10);            var numLoan = (text * opts.barLength)/10;            $this.html(text+"%");            $this.css({"backgroundPositionX": -numLoan + "px"});    });  };  $.fn.progressBar.defaults = {      barLength:277  };})(jQuery);

 

 

//原先的代码

    var bidProgress = function() {        var $bidProgress = $(‘.loanPlanFlg‘);        for(var i = 0; i< $bidProgress.length; i++){                        var text = $bidProgress.eq(i).text();            var index = text.lastIndexOf("%");            text = text.slice(0,index);            text = parseInt(text);            var numLoan = text * 54;            $bidProgress.eq(i).html(text+"%");            $bidProgress.eq(i).css({"backgroundPositionX": -numLoan + "px"});        }    }

 

进度条【改进】