I have done next and prev button functionality. I need to make it so that what happens when I click on the next button, then the same thing happen reversely when clicking on the previous button.
Here I have worked fiddle Link: http://jsfiddle.net/thilakar/t8v5P/
$(function() {
//var a = '.mainList';
var a = 0;
var b = 2;
$('#next').click(function() {
var x = 0;
var z = $('.mainList').length;
$('.mainList').each(function() {
if(a == x){
var inner_li = $('#'+a+' ul li').length;
for( c=1; c<=inner_li; c++ ){
if (c == b) {
if ($('#'+a+'_'+c)) {
$('#'+a+'_'+c).show();
}
} else {
$('#'+a+'_'+c).hide();
}
if(b > inner_li) {
if (x < z-1) {
$('#'+a).hide();
a++;
$('#'+a).show();
b=1;
}
}
}
}
x++;
});
b++;
});
});
Please help me out.
here is the solution in pure jQuery way.
Demo : http://jsfiddle.net/t8v5P/6/