Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda