setInterval(function() {
var $current = $('#slid-1 input[type=radio]:checked');
var $next =$current.next('input');
if(!$next.length) $next = $('#slid-1 input[type=radio]').first();
$next.prop('checked', true);
}, 3000);
Do you have the HTML structure? Would be easier to make this conversion if I see the DOM.
Try to check this with your HTML structure.
setInterval(() => {
let $current = document.querySelectorAll('#slid-1 input[type=radio]:checked'),
$next = $current.nextSibling;
if (!$next.length) {
$next = document.querySelectorAll('#slid-1 input[type=radio]').firstChild;
}
$next.setAttribute('checked', true);
}, 3000);
1 Like
Here is the html Structure
<div class="csslider infinity" id="slid-1">
<input type="radio" name="slides" checked="checked" id="slides_1"/>
<input type="radio" name="slides" id="slides_2"/>
<input type="radio" name="slides" id="slides_3"/>
<input type="radio" name="slides" id="slides_4"/>
<input type="radio" name="slides" id="slides_5"/>
<input type="radio" name="slides" id="slides_6"/>
<ul>
<li>Slide 1</li>
<li>Slide 2</li>
<li>Slide 3</li>
<li>Slide 4</li>
<li>Slide 5</li>
<li>Slide 6</li>
</ul>
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>
) will also add backticks around text.
Note: Backticks are not single quotes.
1 Like