1
I tried to create a progressive and regressive counter to mark on what tag
this 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>
Note that reverse the counter, does not work in an expected way, which would be equal to advancing, jumping from one-on-one house. I’ve made several modifications and resulted in nothing.
I need you to help me solve this little misconception. Go back the way you went forward signaling of one in one