JSFiddle - React, Tailwind, and code Playground
by J4C0814N
HTML
<div id="1" class="clickable"> Click Here!! </div>
<div id="2" class="clickable"> Click Here!! </div>
<div id="3" class="clickable"> Click Here!! </div>
<div id="Clicked"></div>
JavaScript
$('.clickable').click(function(){
// Reset the color of all clickable elements
$('.clickable').css("background-color","white");
// Display which element we clicked
$('#Clicked').html('You Clicked Div: ' +this.id);
// Set the background color of the clicked element
$(this).css("background-color","lightgreen");
});