JSFiddle - React, Tailwind, and code Playground
by Anand Rathod
HTML
<div data-my-element="value1">click 1</div>
<div data-my-element="another">click 2</div>
<div data-my-element="oneMore">click 3</div>
<section class="anand" data-my-element="value1">aa</section>
<section class="anand" data-my-element="another">aa</section>
<section class="anand" data-my-element="oneMore">aaa</section>
CSS
.clicked{
color:red;
}
.section{
color:red;
background-color:red;
}
JavaScript
$('div').click(function() {
var myEm = $(this).attr('data-my-element');
$('.anand[data-my-element = '+myEm+']').addClass('clicked');
});