Search code examples
javascriptjquerytoggleclassadvanced-custom-fields

.toggle() applying to everything in ACF repeater


$( ".employee-big" ).click(function() {
  $( ".info" ).toggle( "slow" );
});

//these are repeaters so class gets repeated
<div class="employee big">
   <div class="info"></div>
</div>

so i have divs that when you click on it it shows the employee's info, these are advanced custom field repeaters in wordpress so the same class is repeated on each employee that gets added. is there a way i can just target the employee that gets the click so the toggle doesnt apply to every employee when you click on one?


Solution

  • Try this

    $( ".employee-big" ).click(function() {
      $(this).find( ".info" ).toggle( "slow" );
    });