JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Show Only One / Toggle text test</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
function showonlyone(thechosenone) {
$('div[name|="content1"]').each(function(index) {
if ($(this).attr("id") == thechosenone) {
$(this).delay(200).fadeIn(500);
}
else {
$(this).fadeOut(100);
}
//Trying to have button text go bold when related div content is shown - and even with a separate if/else clause for each div id it's obviously not working... :)
if ($('#content1').css('opacity') == '0') {
$('#aTag1').css("font-weight","300");
}
else {
$('#aTag1').css("font-weight","bolder");
}
if ($('#content2').css('opacity') == '0') {
$('#aTag2').css("font-weight","300");
}
else {
$('#aTag2').css("font-weight","bolder");
}
});
}
</script>
</head>
<body style="font-family:Arial, Helvetica, sans-serif">
<table>
<tr>
<td style="padding-right:20px;">
<ul>
<li><a id="aTag1" href="javascript:showonlyone('content1')">Show Content 1</a></li>
<li><a id="aTag1" href="javascript:showonlyone('content2')">Show Content 2</a></li>
</ul>
</td>
<td>
<div name="content1" id="content1" style="background-color:#CCC; display:none;">
<ul>
<li>CONTENT1</li>
<li>CONTENT1</li>
</ul>
</div>
<div name="content1" id="content2" style="background-color:#CCC; display:none;">
<ul>
<li>CONTENT2</li>
<li>CONTENT2</li>
</ul>
</div>
</td>
</tr>
</table>
</body>
</html>