2
I have the source code already written. Check out 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 the need arose to show only the four first numbers of pagination, leaving it so:
< 1 2 3 4 >
The rest is hidden. So when you click on "next/previous" should go vanishing and showing the new elements. See:
< 2 3 4 5 >
< 3 4 5 6 >
< 4 5 6 7 >
so on and so forth ...
In other words it would be a "roulette". That’s right in the shape of a "carousel"
I think it would be something like incrementar-e-decrementar
in javascript
But how to implement this to source code?
I really appreciate your effort to help me.
– Diego Henrique