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

88
Visualizações
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 Respostas
Responde à pergunta

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 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