javascript - Twitter-Bootstrap 进度条每 x 秒 100%

标签 javascript css twitter-bootstrap

是否可以让 Bootstrap 进度条每隔 5 秒达到 100%

    <div class="progress progress-striped active">
      <div class="bar" style="width: 40%;"></div>
        </div>

进度条是通过 width 样式填充的,所以上面会把它放在 40% 完成

我如何让它在 5 秒内顺利加载到 100%,然后重新设置为 0 并重新开始,重复进行?

谢谢。

最佳答案

在这个答案中,我稍微修改了@Blender 的方法以永远运行。

为此,我使用了 animate 函数的 complete 参数。
http://jsfiddle.net/xXM2z/490/
完整的 JS 代码:

$(document).ready(function(){
   animateScroll();
});

function animateScroll()
    {
    $('.bar').animate({
    width: '100%'
}, {
    duration: 5000,
    easing: 'linear',
    complete:function(){ $(this).css("width","0%");
   }
});
animateScroll();
}

关于javascript - Twitter-Bootstrap 进度条每 x 秒 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13104361/

相关文章:

javascript - 如何找到 0 - 100 之间的质数?

html - 图像显示在边缘

c# - DropDownList Bootstrap 样式

drop-down-menu - Bootstrap 下拉菜单不起作用

javascript - 通过复选框选择隐藏动态谷歌地图标记

javascript - 我需要为 javascript 数组设置默认选项(下拉字段)

javascript - 使用 React hook useState 在其中一个单元格悬停时突出显示表格的一行时出现问题?

jquery - 如何将加载微调器添加到 WooCommerce 结帐页面

html - 如何在启用 bootstrap 的 html 表的元素之间添加间距?

javascript - 如何回显图像路径并将其附加到codeigniter中的ajax成功函数之后?