<script type="text/javascript">
$(document).ready( function() {
var totalPage=$("ul li").length;
var total = Math.ceil($("ul li").length / 5);
var current = 1;
//var index =4;
if(totalPage>5){
$("ul li:gt(4)").hide();
$("#btnPrev").attr("class", "tabs-scroller-left-disabled").attr("disabled", "disabled").click( function() {
debugger;
$("#btnNext").attr("class", "tabs-scroller-right");
$("#btnNext").removeAttr("disabled");
current -= 1;
var tt=current;
$("ul li").show();
var indexStart = (current - 1);
var indexEnd = indexStart + 4;
$("li:lt(" + indexStart + "), li:gt(" + indexEnd + ")", $("ul")).hide();
if (current == 1){
$(this).attr("class", "tabs-scroller-left-disabled");
$(this).attr("disabled", "disabled");
}
});
$("#btnNext").click( function() {
debugger;
$("#btnPrev").attr("class", "tabs-scroller-left");
$("#btnPrev").removeAttr("disabled");
current += 1;
$("ul li").show();
var indexStart = (current - 1);
var indexEnd = current + 4 > $("ul li").length - 1 ? $("ul li").length - 1 : current +3;
$("li:lt(" + indexStart + "), li:gt(" + indexEnd +")", $("ul")).hide();
if (current+4 >= totalPage){
$(this).attr("class", "tabs-scroller-right-disabled");
$(this).attr("disabled", "disabled");
}
});
}else{
alert(1);
$("#btnPrev").attr("class", "tabs-scroller-left-disabled");
$("#btnNext").attr("class", "tabs-scroller-right-disabled");
}
});
</script>
您可能感兴趣的文章: