I have a few tables on my page, but I'm displaying only three of them, when I click next, the table with lowest ID disappears, and another, hidden table appears.
when I click previous, the highest ID disappears and hidden table with lower ID appears.
My css:
table.invisible{ display: none }
My html:
<button id="next"></button><button id="prev"></button>
<table id="1" class="visible" >...</table>
<table id="2" class="visible" >...</table>
<table id="3" class="visible" >...</table>
<table id="4" class="invisible" >...</table>
<table id="5" class="invisible" >...</table>
<table id="6" class="invisible" >...</table>
My JS:
$("#next").click(function(){
$(lowest_visible_id).removeClass('visible');
$(lowest_visible_id).addClass('invisible');
$(highest_visible_id+1).removeClass('invisible');
$(highest_visible_id+1).addClass('visible');
});
$("#prev").click(function(){
$(highest_visible_id).removeClass('visible');
$(highest_visible_id).addClass('invisible');
$(lowest_visible_id-1).removeClass('invisible');
$(lowest_visible_id-1).addClass('visible');
});
IT ALL WORKS. But it works in very simple way - one table hides, another shows and that's it - can you give me some suggestions how to make it look nicer? (I suppose using jquery, but I've tried with miserable effects :) )