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

411
Views
Si el campo repetidor contiene valor (¿cómo obtener la matriz?)

tengo una tabla #mytable con una columna

 <table id="#mytable"> <tr><td class="name">John</td></tr> <tr><td class="name">Paul</td></tr> <tr><td class="name">Mary</td></tr> </table>

Quiero agregar una clase si el nombre está contenido en una matriz. Así que hice lo siguiente:

 jQuery.each($('#mytable .name'), function () { var line = $(this).closest("tr"); var name = this.textContent; if (['David','Paul','Melissa'].includes(name)) { line.addClass("yes"); } });

Esto funciona bien, la clase .yes se agregará a la segunda línea, la que contiene a Paul.

Sin embargo, mi problema es cuando intento obtener la matriz real. Los valores están contenidos en un subcampo repetidor. Así que agregué una variable e intenté reemplazar la matriz por mi variable:

 jQuery.each($('#mytable .name'), function () { var line = $(this).closest("tr"); var name = this.textContent; var repeaternames = $('#myrepeater .names .acf-input .select2-selection__rendered'); if (repeaternames.includes(name)) { line.addClass("yes"); } });

Pero esto no funciona. ¿Es un problema de sintaxis, es porque mi variable "repetidores de nombres" no es una matriz real?

¿O porque no estoy obteniendo los valores correctos? Como puede ver, los valores repetidores que estoy tratando de obtener están en un campo de selección select2, y tal vez no estoy apuntando a los elementos correctos.

Gracias de antemano por su ayuda !!

about 4 years ago · Juan Pablo Isaza
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!