我使用这个写得不好的代码在html中添加或减去一个数字。
在第一个索引中,输出将如下所示:
1/ 6
在最后一个索引上,它将如下所示:
6/ 6
这与pageslide.js一起使用。这是我对内置分页系统的替代。还有更聪明的写这个吗?
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/ ");
}发布于 2014-09-20 12:39:24
如果不需要对值进行筛选或检查,请执行以下操作:
$( ".sectionCurrent" ).text(index + "/ ");如果值需要介于1/6之间:
if(index > 0 && < 7){
$( ".sectionCurrent" ).text(index + "/ ");
}https://stackoverflow.com/questions/25948832
复制相似问题