I tried to create a progressive and regressive counter to mark that tag
is stopped.
Code
el = document.getElementsByTagName('a')
var x = 0,
y = 0;
document.getElementById('menos').onclick = function() {
x--;
if (y == 3 || x == 0)
alert("Limite!");
else {
el[x].className = 'ativo';
el[y].className = '';
}
y++;
}
document.getElementById('mais').onclick = function() {
x++;
if (y == 3 || x == 4)
alert("Limite!");
else {
el[y].className = '';
el[x].className = 'ativo';
}
y++;
}
a {
cursor: pointer; padding: 3px; text-decoration: none; color: #111;
}
a.ativo {
font-weight: bolder;
background-color: #333;
color: #fff;
}
<button id="menos">« Anterior</button>
<a href="#A" class="ativo" >1</a>
<a href="#B">2</a>
<a href="#C">3</a>
<a href="#D">4</a>
<button id="mais">Próximo »</button>
See that backing up the counter does not work as expected, it would be the same as moving forward, hopping one-on-one home. I made several changes and it did not work.
I need you to help me solve this small misunderstanding. Go back the same way you went signaling one by one