JSFiddle - React, Tailwind, and code Playground

by ojtramp

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
  <button class="a">Change color</button>
  <button class="b">Another Button</button>
  <button class="c">Change color</button>
</div>

<div>
  <button class="a">Change color</button>
  <button class="b">Another Buttor</button>
  <button class="c">Change color</button>
</div>

JavaScript

$(".c").on("click", function() {
  $(this).parent().find('.a').css('background','red');
})

$(".a").on("click", function() {
  $(this).next('.c').css('background','red');
})