JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<body>
<h4 class="b" id="b1">B1</h4>
<h4 class="b" id="b2">B2</h4>
<h4 class="b" id="b3">B3</h4>
<hr/>
<section id="section1" class="hideme">
section1
</section>
<section id="section2" class="hideme">
section2
</section>
<section id="section3" class="hideme">
section3
</section>
</body>
</html>
CSS
.hideme {
background-color: lime;
}
JavaScript
$(document).ready(function() {
$("section.hideme").hide();
$("h4.b").click(function() {
var id = $(this).attr("id");
var sectionId = id.replace("b", "section");
$("section.hideme").hide();
$("section#" + sectionId).fadeIn("slow");
});
});