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

414
Vistas
If repeater field contains value (how to get the array?)

I have a table #mytable with a column

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

I want to add a class to if the name is contained in an array. So I did the following :

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

This works fine, the class .yes will be added to the 2nd line, the one containing Paul.

However, my problem is when trying to get the actual array. The values are contained in a repeater subfield. So i added a variable and tried to replace the array by my 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");
    }       
  });

But this doesn't work. Is it a syntax issue, is it because my "repeaternames" variable is not an actual array ?

Or because I'm not getting the right values? As you can see, the repeater values that I'm trying to get are in a select2 select field, and maybe i'm not targeting the right elements.

Thank you in advance for your help !!

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