I want my bootstrap tabs to automatically tab but when a tab is clicked i want the tabbing to pause for a certain amount of time or stop completely. Here is the piece of javascript i am using.
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
});
If you have not already solved it ... here is your fiddle you can check.
// 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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With