0
I want to create an automatic counter, which is marked in what number is every second.
In order for that to happen, I have in mind that he must jump from one element <a>
to another every second.
I’m running tests manually, then programming the auto-countdown.
The whole logic is simple, with each click a descent to a previous number
Code
el = document.getElementsByTagName('a')
var x = 0, y = 0;
function voltar()
{
if(y == 6 || x == 0)
alert("Limite!");
else {
el[x].style.color = "red";
el[y].style.color = "black";
}
x--;
}
a
{
text-decoration: none;
cursor: pointer;
padding: 3px;
color: black;
}
<a onclick="voltar(x--)" id="menos">Você está no:</a>
<a>1</a>
<a>2</a>
<a>3</a>
<a>4</a>
<a style="color:red">5</a>
Every click in the word You’re in the: then he should go down to the minor number/predecessor
NOTE - the previous color should be restored, leaving in red color only the number highlighted.
Do not forget to pass as a parameter in the function the number of numbers you have in the anchors. Thus, you have the flexibility to create as many anchors as needed, such as:
<a>..</a>
<a>10</a>
<a>11</a>
<a>12</a>
In this case, you must pass 12 as the starting parameter.– Andrew Ribeiro