I have the source code already written. Check below:
var str = "ABCDEFGHIJKLMNOPQRSTUVXWYZ"
var link = [];
for(var i = 0; i < str.length; i++)
{
var letra = str.charCodeAt(i) - 64;
link[i] = "<a href='base/dados/"+ letra +".html' target='resultado'>" + (i+1) + "</a>";
}
document.getElementById("listagem").innerHTML = link.join(" ");
window.onload = document.getElementsByTagName('a')[0].className="hover"
var pag = document.getElementsByTagName('a')
var contar = 0;
function troca(i) {
if (i == 'e') {
if (contar > 0) {
pag[contar].className = ""
contar--;
pag[contar].className += "hover";
}
} else {
if (contar < pag.length - 1) {
pag[contar].className = ""
contar++;
pag[contar].className += "hover";
}
}
}
a {
text-decoration: none;
cursor: pointer;
padding: 1px 4px 1px 4px;
color: black;
}
a.hover {
color:red;
font-weight: bolder;
background-color: red;
color: white;
}
a:hover {
color:red;
font-weight: bolder;
background-color: red;
color: white;
}
.seta {
cursor: pointer;
}
<div id="resultado"></div>
<button onclick="troca('e')" id="menos" class="seta">«</button>
<span id="listagem"></span>
<button onclick="troca('d')" id="mais" class="seta">»</button>
But there was a need to show only the four first paging numbers, thus leaving it:
< 1 2 3 4 >
The rest is hidden. So when you click on next previous you should go dropping and showing the new elements. See:
< 2 3 4 5 >
< 3 4 5 6 >
< 4 5 6 7 >
so on ...
In other words it would be a " roulette ". That's even in the form of a carousel "
I think it would be something like incrementar-e-decrementar
in javascript
But how to implement this to source code ?