If i click right button, the left button shows up, and if I'm at the last page, the right button hides. But now it happens for both sections, is it possible to make one code for them to count seperate ?
I made it possible with different id's but that's not really what i want. Because if I have more than 10 rows, it's hard code problem.
Is this possible with jquery ?
HTML
<section>
<div class="left" id="links"><div>
<div class="right" id="rechts"><div>
</section>
<section>
<div class="left" id="btn-l"><div>
<div class="right" id="btn-r"><div>
</section>
CSS
#links {
text-align: center;
width:50px;
height: 100px;
border: 1px solid red;
position: absolute;
left: 10px;
top: 145px;
z-index: 100;
}
#rechts {
text-align: center;
width:50px;
height: 100px;
border: 1px solid red;
position: absolute;
right: 10px;
top: 145px;
z-index: 100;
}
#btn-l {
text-align: center;
width:50px;
height: 100px;
border: 1px solid red;
position: absolute;
left: 10px;
top: 310px;
z-index: 100;
}
#btn-r {
text-align: center;
width:50px;
height: 100px;
border: 1px solid red;
position: absolute;
right: 10px;
top: 315px;
z-index: 100;
}
Jquery
var page1 = 0;
$('.left').hide();
$('.right').click(function(){
$('.left').show();
page1+= 1;
if(page1 >= 3) {
$('.right').hide();
}
});
$('.left').click(function(){
page1-=1;
if(page1<3){
$('.right').show();
}
if(page1 == 0){
$('.left').hide();
}
});
<div class="left" id="links"><div>must be<div class="left" id="links"></div>and so on...