JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<div class="btn" id ="btn-1" data-showbutton="1"></div>
<p class="text" data-button="1">
HI i'm numbr 1
</p>
<div class="btn" id ="btn-2" data-showbutton="2"></div>
<p class="text" data-button="2">
HI i'm numbr 2
</p>
</div>
CSS
#container
{
height:400px;
width:400px;
position:relative;
}
.btn{
width : 50px;
height : 50px;
border-radius : 50px;
background-color : green;
margin:10px auto;
}
.text
{
position:absolute;
color:red;
font-size:24px;
font-weight:bold;
left:150px;
top:150px;
display:none;
}
.clicked{
border : 3px solid #000;
}
JavaScript
$('#btn-1,#btn-2').click(function(){
var btn = $(this).data("showbutton");
showButtonText(btn);
});
function showButtonText(btn) {
// reset
$('.text').hide();
$('[data-button]').hide();
$('[data-showbutton]').removeClass('clicked');
// only show the selected
$('[data-showbutton=' + btn + ']').addClass('clicked');
$('[data-button=' + btn + ']').show();
}