JSFiddle - React, Tailwind, and code Playground

by isherwood

HTML

<div id="engaged">Engaged</div>
<div id="one" class="myCommonClass">One (orange)</div>
<div id="two" class="myCommonClass">Two (green)</div>

CSS

.myCommonClass {
    cursor: pointer;
}
.one {
    color: orange;
}
.two {
    color: green;
}

JavaScript

$('.myCommonClass').click(function () {
    var myStr = $(this).attr('id').replace('#', '');

    $('#engaged').attr('class', '').addClass(myStr);
});