3
Hello I do not have much experience with js and I am with a problem believe that silly but that there are days trying to solve and I can not. I created a list of HTML elements with the following structure:
HTML
<ul id="NumerosAdicionados" class="fa-ul">
<h6><strong>Numero(s) inserido(s)</strong></h6>
</ul>
Function that adds numbers
var listaNumeros = [];
function adicionaNumeros() {
var i = listaNumeros.length;
listaNumeros.push(i);
$("#NumerosAdicionados").append("<li id=" + i + " value=" + i + "><i class='fa fa-times-circle' onclick=excluiNumero(" + i + ")></i>" + i + "</li>");
}
Function excluding the numbers
function excluiNumero(indice) {
listaProcessos.splice(indice, 1);
}
With this code it removes the element from the list, but does not remove it from the HTML, only when selecting the first element to delete it deletes all of the HTML.
What is
listaProcessos
?– Samir Braga
Possible duplicate of Remove more than one item from an array
– Randrade
@Randrade, the problem presented by AP is related to dynamic modification in HTML, and it can already delete the array item. I think this question, although it is very similar, does not mention it, but I could be wrong.
– Samir Braga
@Samirbraga If the doubt of the AP is that same, you are right. I had understood that it was something in relation to the
.splice()
.– Randrade
My doubt was not about the splice no, it was like displaying even the html after the item exluded.
– Ana Carolina
And you want to assign new numbers, or you can have 1.2.5.6 in case you excluded 3 and 4?
– Sergio