JSFiddle - React, Tailwind, and code Playground

HTML

<div class="shikhar">
    <div class="a">Superman</div>
    <div class="b">Hulk</div>
</div>
<div class="shikhar">
    <div class="a">Spiderman</div>
    <div class="b">Batman</div>
</div>

CSS

.selected {
    color:red;
}
.highlight {
    background:yellow;
}

JavaScript

$(document).ready(function () {

    $('.shikhar > div').click(function (e) {

        var decide = $(this).attr('class');
        //here I want to know what was the class of the element that was clicked
        alert(decide);

        if (decide == 'a') {
            $(this).parent().find('.b').addClass("selected");
            $(this).parent().find('.a').addClass("highlight");
        } else {
            $(this).parent().find('.a').addClass("selected");
            $(this).parent().find('.b').addClass("highlight");
        }

    });



});