I am dealing with 5 divs that have text content inside.
To navigate through each div, I have implemented a back and next button system.
<a href="" class="back-btn off">Back</a> | <a href="" class="next-btn">Next</a>
<div class="vote-result first">
This is an example text
</div>
<div class="vote-result">
Here is some more text
</div>
<div class="vote-result">
More text to read
</div>
<div class="vote-result">
This is the final section of text
</div>
// Hiding all divs except for the first one initially.
.vote-result { display: none; }
.vote-result.first { display: block; }
On the first click of the next button, I want to remove the 'off' class to make it clickable. Initially, the link should be disabled and later re-enabled.
$(".back-btn").removeClass("off");
When the last div is reached, I need to add the 'off' class to the next-btn to disable it.
Although I considered using a carousel JavaScript plugin for this functionality, I feel it's unnecessary at the moment.
I have thought about a solution involving sub-classes for the links based on which button was clicked (back or next), to determine which div should be displayed next and manage the state of the buttons accordingly.
I would like to find a way to incorporate additional divs without having to modify the existing code. Any suggestions are welcome, thank you.