JSFiddle - React, Tailwind, and code Playground
HTML
<div id="main">
<div class="item"><a href="#" name="a">Link to div A</a></div>
<div class="item"><a href="#" name="b">Link to div B</a></div>
<div class="item"><a href="#" name="c">Link to div C</a></div>
</div>
<div class="item" id="a" style="display:none;">Link to div <a href="#" name="b">B</a> and <a href="#" name="c">C</a></div>
<div class="item" id="b" style="display:none;">Link to div <a href="#" name="a">A</a> and <a href="#" name="c">C</a></div>
<div class="item" id="c" style="display:none;">Link to div <a href="#" name="a">A</a> and <a href="#" name="b">B</a></div>
JavaScript
$(document).ready(function() {
// Hook up the first divs
$(".item a").click(function() {
// Get the target from the name of the anchor
var targetDiv = $(this).attr("name");
// Show the new div and hide the parent div
$("#" + targetDiv).css("display", "");
$(this).parents("div:last").css("display", "none");
});
});