Having trouble with a custom carousel and unable to use the standard Bootstrap carousel.
This is how my code is structured:
Images:
<img src="1.img"/>
<img src="2.img"/>
<img src="3.img"/>
Prev / Next buttons:
<div class="left"></div> left button
<div class="right"></div> right button
These buttons navigate through elements in the "ol" table.
Ol Table:
<ol>
<li>Circle 1</li>
<li class="active">Circle 2</li>
<li>Circle 3</li>
</ol>
Clicking on a button loads data corresponding to that element, marking it as active.
The issue lies with the Prev / Next buttons operation. Given an HTML "ol" with three elements, I need them to cycle properly when clicked.
Starting from the second element with an active class, I aim to use jQuery prev() and next() functions in a for loop to ensure correct navigation behavior.
Current logic on click of "next" (and vice versa with "prev") buttons:
$("li.active").next().addClass("active");
$("li.active").prev().removeClass("active");
Encountering two problems: 1) Selection issues between elements when clicking to navigate forward. 2) Incorrect element selection when navigating backwards. A for loop seems necessary to address these challenges. Can anyone assist with this? Thank you.