需要实现效果如下图。
页面代码第一次进入页面调用。或每次赋值或更改值时调用方法 function updataProgressBar(){ //更新进度条信息
//进度条设置 var $color=$('.progress_bar').attr('data-color'); //data-color 为进度条颜色 例#ff6600 $('.progress_bar').each(function () { var per=$(this).attr('data-per'); //data-per 为进度条 进度值 1-100 var barWidth=$(this).attr('data-width'); //data-width 为进度条宽度 值自定义 单位自动填充px $(this) .find('span').css({'background' : $color , 'width' : per + '%'}) .parent().css({'width' : barWidth}) .next().text(per+'%'); }) }