我正在使用一个进度条和一个按钮。
我可以让进度条在Pageload上设置一个值,但是我无法使用按钮随时间增加它。我尝试使用HTMl onClick和jQuery .click(function(){无济于事,过去2小时都试图这样做,我放弃了。
使用第二个div中的宽度%设置进度条值。
HTML:
<div class="progress progress-striped active" style="width:400px;">
<div class="progress-bar" width="40%"></div>
</div>
<button id="code" type="button" class="btn btn-success" style="width:400px;">Generate Code</button>
想要在不需要安装插件的情况下执行此操作。
TL;博士
我需要获得一个引导进度条,以便在按钮点击事件时随着时间的推移而增加。
感谢。
答案 0 :(得分:3)
只需设置进度条元素的宽度
即可//this sets a random width
$('.progress-bar').width((Math.random() * 100) + '%')
演示:Fiddle