I have a set of questions and want to display a simple progress counter above them. The code below works fine but I was wondering if somebody could advise on refactoring as theres got to be a better way of achieving this.
var totalCount = $('#questions li').length,
count = 1;
$('.progress').html("Question " + count + " of " + totalCount);
// Increment by 1 on each click
$('.btn-next').click(function(){
count ++ ;
// remove current count
$('.progress').empty();
// drop in new count
$('.progress').html("Question " + count + " of " + totalCount);
});
// Decrease by 1 on each click
$('.btn-prev').click(function(){
count -- ;
// remove current count
$('.progress').empty();
// drop in new count
$('.progress').html("Question " + count + " of " + totalCount);
});