-2
The intention is to run the first five [5] Carnidais numbers in sequence by displaying five-in-five, but the previous ones should be deleted and then run another five [10] (from 6 to 10) until reaching a certain limit imposed within the function, that is, it will be determined to what extent these numerals will be applied by the 'increment' and 'de-create' buttons. This is how I’ve been trying:
var spn = document.getElementsByTagName('span');
function mostrarGrupo() {
// Limitar o número de números a serem exibidos
var inicio = 5;
// Correr elementos span afim de quantificar
for (var i = 0; i < spn.length; i++) {
spn[i].innerHTML += inicio + 1;
inicio++
}
}
function esconderGrupo() {
// Limitar o número de números a serem exibidos
var inicio = 5;
// Correr elementos span afim de quantificar
for (var i = 0; i < spn.length; i--) {
spn[i].innerHTML += inicio + 1;
inicio--
}
}
<center>
<button id="menos" onclick="esconderGrupo">-</button>
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<button id="mais" onclick="mostrarGrupo">+</button>
</center>
At the moment I am thinking of other solutions for this purpose. However, I would like to hear or see what you suggest to me?


Aside from the already mentioned typo (missing parentheses when calling functions), I think that
esconderGrupoandmostrarGrupoare not good names, because nothing is actually being hidden, and the information is always shown (I thinkincrementarGrupoanddecrementarGrupowould be better, because that is what is being done). Suggestion: https://jsfiddle.net/ez7L6b8c/1– hkotsubo