使用索引jQuery添加或减去数字

使用索引jQuery添加或减去数字,jquery,html,Jquery,Html,我正在使用这段写得很糟糕的代码在html中添加或减去一个数字 第一个索引上的输出如下所示: 1/6 在最后一个索引上,它将如下所示: 6/6 这与pageslide.js一起使用。这是内置分页系统的替代方案。 有没有办法写得更聪明一些 if(index == '1'){ $( ".sectionCurrent" ).text("1/ "); } if(index == '2'){ $( ".sectionCurrent" ).text("

我正在使用这段写得很糟糕的代码在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/ ");
    }

如果不需要筛选或检查值,请选择:

$( ".sectionCurrent" ).text(index + "/ ");
如果该值需要介于1/6之间:

if(index > 0 && < 7){
   $( ".sectionCurrent" ).text(index + "/ ");
}
if(索引>0&<7){
$(“.sectionCurrent”).text(索引+“/”);
}