Reputation: 1549
I'm using this poorly written code to add or subtract a number within the html.
The output will look like this on the first index:
1/ 6
On the last index it will look like this:
6/ 6
This is used together with pageslide.js. This is my alternative to the built in pagination system. Is there anyway to write this smarter?
if(index == '1'){
$( ".sectionCurrent" ).text("1/ ");
}
if(index == '2'){
$( ".sectionCurrent" ).text("2/ ");
}
if(index == '3'){
$( ".sectionCurrent" ).text("3/ ");
}
if(index == '4'){
$( ".sectionCurrent" ).text("4/ ");
}
if(index == '5'){
$( ".sectionCurrent" ).text("5/ ");
}
if(index == '6'){
$( ".sectionCurrent" ).text("6/ ");
}
Upvotes: 1
Views: 91
Reputation: 509
If you don't need filtering or checking of the value go for:
$( ".sectionCurrent" ).text(index + "/ ");
If the value needs to be between 1/6:
if(index > 0 && < 7){
$( ".sectionCurrent" ).text(index + "/ ");
}
Upvotes: 2