I have bootstrap Accordion. And I need somehow to run it automatically. To open tab by tab. Currently, I wrote this function But it isn't so smooth as I want. Maybe there is a worked library for that or something.
var index = 5;
function foo (condition) {
// do stuff
if(index !== 5){
index--;
}
$('#accordion').accordion()
let active = $('#accordion').accordion('option', 'active')
$('#accordion').accordion('option', 'active', active)
$('#accordion').accordion('option', 'active', active)
if (index < 10) {
$('#accordion').accordion('option', 'active', active + 1)
index++
} else {
$('#accordion').accordion('option', 'active', active - 1)
}
setTimeout(foo, 2000)
console.log(index)
}
foo()
Try this: