gpt4 book ai didi

javascript - 自动 Bootstrap 选项卡

转载 作者:搜寻专家 更新时间:2023-11-01 04:57:26 25 4
gpt4 key购买 nike

我希望我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com