Let's suppose, I click the More button and I go ahead with A - Z
.
Now I want to go back from Z - A
clicking the Minus button.
Code:
var i = 0;
var j = 0;
var n = 0;
function prox(){
j++;
i += 20;
barra = texto.split("|");
document.getElementById('lista').innerHTML = ' ';
for ( x = n; x < i; x++ ){
if(barra[x]){
document.getElementById('lista').innerHTML += "<br>"+barra[x]+"<br>";
}
}
if (j) {n = i}
}
function ante(){
j--;
i -= 20;
barra = texto.split("|").reverse();
document.getElementById('lista').innerHTML = ' ';
for ( p = n; p > i; p-- ){
if(barra[p]){
document.getElementById('lista').innerHTML += "<br>"+barra[p]+"<br>";
}
}
if (j) {n = i}
}
texto =
// clique 1 - listagem 1
"|A|"+
"|B|"+
"|C|"+
"|D|"+
"|E|"+
// clique 2 - listagem 2
"|F|"+
"|G|"+
"|H|"+
"|I|"+
"|J|"+
// clique 3 - listagem 3
"|K|"+
"|L|"+
"|M|"+
"|N|"+
"|O|"+
// clique 4 - listagem 4
"|P|"+
"|Q|"+
"|R|"+
"|S|"+
"|T|"+
// clique 5 - listagem 5
"|U|"+
"|V|"+
"|W|"+
"|X|"+
"|Y|"+
"|Z|";
<div id="lista"></div>
<hr color=silver size=1>
<a onclick="ante();">« Menos</a>
|
<a onclick="prox();">Mais »</a>
But this Minus button is not responding correctly!