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

92
Vistas
jQuery get list items as text and display them in a confirm

I have a small confirm that displays data on the page for the user to re-read and to see if he made any mistakes and I have included a list of categories but I can't manage to display them in the confirm My code is below:

            $("#add_campaign").on('submit', function(event){
            if(!confirm("Confirm:\n" +
                
                "\nCategorii selectate: " + categoriesInConfirm() +
                
                "\nContinue?")) {
                event.preventDefault();
            }
        });
    });

    function categoriesInConfirm()
    {
        $('#newCategories li span').each(function (index,value){
             $(value).text())
        })
    }

I used the following line in my console to check if I can get the list and it works:

$('#newCategories li span').each(function (index,value){console.log($(value).text())})

I don't know how to implement it in my coding environment

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your function needs to return value like this.

function categoriesInConfirm()
{
    var cats = '';
    $('#newCategories li span').each(function (index,value){
        console.log($(this) + ' ,' + $(this).text());
        cats += $(this).text() +', ';
    });
    cats = cats.substring(0, cats.length - 2); // remove last , 
    return cats;
}
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