I recommend using the jQuery Cycle plugin. Imagine the slides are an unordered list:
<ul id="slides">
<li class="slide">...</li>
...
</ul>
<a id="prev">></a><span id="counter">1 / 1</span><a id="next"><</a>
You can get the total number of slides just by calling:
var total = $('#slides').children().length;
Then we need to update the counter after changing the slides:
$('#slides').cycle({
after: function(i){
var currentSlideNo = $(i).index();
$('#counter').text(currentSlideNo+' / '+total);
},
prev: $('#prev'),
next: $('#next')
});
source
share