As someone new to development, I am looking for a way to scroll my question pallet up and down based on the question number when I click next and previous buttons.
In my pallet div, there are over 200 questions which are dynamically generated. However, there may be instances where there are fewer than 200 questions.
Here is a snippet of my code:
Within my next button, I have the following function written:
function next(id) {
if (id >= 40 && id < 79) {
$(".question-container").animate({scrollTop: 370}, 'fast');
}
if (id > 80 && id < 119) {
$(".question-container").animate({scrollTop: 740}, 'fast');
}
if (id > 120 && id < 159) {
$(".question-container").animate({scrollTop: 1110}, 'slow');
}
if (id >= 160 && id < 200) {
$(".question-container").animate({scrollTop: 1480}, 'slow');
}
if (id >= 200 && id < 240) {
$(".question-container").animate({scrollTop: 1850}, 'slow');
}
if (id >= 240 && id < 300) {
$(".question-container").animate({scrollTop: 2220}, 'slow');
}
Can anyone provide assistance with this?
Thank you, Thangavel