JSFiddle - React, Tailwind, and code Playground
HTML
<h1>
Hello
</h1>
<p class="active">
hello
</p>
<h1>
Goodbye
</h1>
<p>
Goodbye
</p>
CSS
p {
opacity: 0;
}
.active {
opacity: 1 !important;
}
JavaScript
function classChange() {
if($(this).hasClass('active')) {
//do nothing
}
else {
$('.active').removeClass('active');
$(this).next('p').addClass('active');
}
}
$('h1').click(function() {
classChange();
});