I have an image slider, that has 6 full screen images, and it starts at 1 but then jumps to 3, then 5, then 1, then back to 3 then 5 etc. It seems like the part where checked is set to true in 'else' is being looped on itself twice.
This is the code as it is:
jQuery(document).ready(function( $ ) {
var TIMEOUT = 6000;
var interval = setInterval(handleNext, TIMEOUT);
function handleNext() {
var $radios = $('input[class*="slide-radio"]');
var $activeRadio = $('input[class*="slide-radio"]:checked');
var currentIndex = $activeRadio.index();
var radiosLength = $radios.length;
$radios
.attr('checked', false);
if (currentIndex >= radiosLength - 1) {
$radios
.first()
.attr('checked', true);
} else {
console.log("checking")
$activeRadio
.next('input[class*="slide-radio"]')
.attr('checked', true);
}
}
});
Here is a link to the page my website