Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
Remove Element from JavaScript array in .NET core Razor

I have input when the user click on add button it should add a new li in the ul list and add a new object in array "Keywords" to send it to the action, but the problem is when the user removes an element from the ul list I remove the index of the element from the array it didn't work however the removal of the li element works well. here is the script:

enter image description here

and this is the HTML:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try to change

delbtns = $(".delete");
        for (var i = 0; i < delbtns.length; i++) {
            delbtns[i].onclick = function () {
                this.parentNode.remove();
                keywords.splice(i, 1);
            }
        }

to

$(".delete").on('click', function (event) {
            var delbtns = $(".delete");
            for (var i = 0; i < delbtns.length; i++) {
                if (this == delbtns[i]) {
                    this.parentNode.remove();
                    keywords.splice(i, 1);
                    break;
                }
            }
        })

result: enter image description here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda