5
我的页面上有2个进度条。一个是静态HTML版本,另一个是通过jQuery动态创建的。如果我想改变jQuery中的宽度,以便进度条“正在进行”,那么只有静态工作正在进行。Bootstrap进度条动态元素 - 动态更改宽度
另一个立即100%没有延迟。
这里是更好的代表性代码: https://jsfiddle.net/gezgind/DTcHh/7133/
HTML
<div class="container">
<div id="reportbars">
<div class="progress" style="width:500px;margin-bottom:0px;margin-top:20px;">
<div class="progress-bar" id="tracking" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;transition-duration: 3s;">
<span style="visibility:hidden">xxxx</span>
</div>
</div>
<button id="report_start" type="button" class="btn btn-default">Start</button>
</div>
JS
$("#report_start").click(function(){
$("#reportbars").append(
'<div class="progress" style="width:500px;margin-bottom:0px;margin-top:20px;">' +
'<div class="progress-bar" id="tracking1" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;transition-duration: 3s;">' +
'<span style="visibility:hidden">Tracking 950.325</span>' +
'</div></div>'
);
$("#tracking").css("width","100%");
$("#tracking1").css("width","100%");
});
如何解决?
非常感谢您!完美的作品。 –
@DenizGezgin兄弟,你正在追加你的进度条并且并行地增加它的宽度。宽度脚本应在追加后执行。 欢呼声! –
清晰易懂+1 –