Ive got an array, which I do a few things to but right now im trying to divide it between ‘pages’ (more like slides really).
I loop through it using the .each() method, calling this lengthy bit of code to place the info on the right page (just 5 items per page, for now atleast).
Is there a way of simplifying this code?
Ideally so it can go on infinitely:
if (index > 0 && index <= 5) {
var page = $('#librarian-page-gallery-1');
} else if (index > 5 && index <= 10) {
var page = $('#librarian-page-gallery-2');
} else if (index > 10 && index <= 15) {
var page = $('#librarian-page-gallery-3');
} else if (index > 15 && index <= 20) {
var page = $('#librarian-page-gallery-4');
} else if (index > 20 && index <= 25) {
var page = $('#librarian-page-gallery-5');
} else if (index > 25 && index <= 30) {
var page = $('#librarian-page-gallery-6');
} else if (index > 30 && index <= 35) {
var page = $('#librarian-page-gallery-7');
} else if (index > 35 && index <= 40) {
var page = $('#librarian-page-gallery-8');
} else if (index > 45 && index <= 50) {
var page = $('#librarian-page-gallery-9');
}
For example :
Explanation :