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

412
Views
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
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!