javascript - 自动 Bootstrap 选项卡

标签 javascript twitter-bootstrap

我希望我的 bootstrap 选项卡自动跳转,但是当单击一个选项卡时,我希望跳转暂停一定时间或完全停止。这是我正在使用的一段 javascript。

    var timer = null, 
    interval = 1000,
    value = 0;

$("#start").click(function() {
  if (timer !== null) return;
  timer = setInterval(function () {
      value = value+1;
      $("#input").val(value);
  }, interval); 
});

$("#stop").click(function() {
  clearInterval(timer);
  timer = null
});

最佳答案

如果您还没有解决它...这是您可以检查的 fiddle 。

// Tab click event handler
$('a').on('click', function (e) {
    e.preventDefault();
    // Stop the cycle
    clearInterval(tabCycle);
    // Show the clicked tabs associated tab-pane
    $(this).tab('show');
    // Start the cycle again in a predefined amount of time
    setTimeout(function () {
        //tabCycle = setInterval(tabChange, 5000);
    }, 15000);
});

http://jsfiddle.net/ahLyZ/1/

关于javascript - 自动 Bootstrap 选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18606773/

相关文章:

Javascript 为什么要将函数原型(prototype)的构造函数分配给函数本身? Programmer.prototype.constructor = 程序员

jquery - JsPlumb: Bootstrap 导航栏填充后错误的 anchor 位置

html - Bootstrap 4 导航栏,无法删除填充

html - Bootstrap "jumbotron-narrow"示例。风格如何变化?

javascript - 检查对象是否包含具有值的属性

javascript - 四舍五入和向下舍入账单金额

javascript - 如何使用 flatlist 集成 react-native-swiper

javascript - 使用 GitHub 页面从 Bootstrap 模板获取联系表单

jquery - 从外部链接自动打开 Bootstrap Modal

javascript - 引用 JSON 子数据