Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
jQuery obtiene elementos de la lista como texto y los muestra en una confirmación

Tengo una pequeña confirmación que muestra datos en la página para que el usuario los vuelva a leer y ver si cometió algún error y he incluido una lista de categorías, pero no puedo mostrarlas en la confirmación Mi código está debajo :

 $("#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()) }) }

Usé la siguiente línea en mi consola para verificar si puedo obtener la lista y funciona:

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

No sé cómo implementarlo en mi entorno de codificación.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su función necesita devolver un valor como este.

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!