JSFiddle - React, Tailwind, and code Playground
HTML
<div style="width: 200px;">
<div id="item1" style="float: left; width: 50px; cursor: pointer;">Item1</div>
<div id="item2" style="float: left; width: 50px; cursor: pointer;">Item2</div>
<div id="item3" style="float: left; width: 50px; cursor: pointer;">Item3</div>
<div id="item4" style="float: left; width: 50px; cursor: pointer;">Item4</div>
<div style="clear: both;"></div>
</div>
<div style="height: 50px;"></div>
<div id="ContentList1" style="display:none">Content 1</div>
<div id="ContentList2" style="display:none">Content 2</div>
<div id="ContentList3" style="display:none">Content 3</div>
<div id="ContentList4" style="display:none">Content 4</div>
CSS
body {
font-family: sans-serif;
width: 90%;
margin: 0 auto;
}
#lower {
position: relative;
padding-top: 10px;
}
#bar {
padding: 10px;
background-color: #CCCCCC;
}
#panel {
display: none;
background-color: #AAAAAA;
padding: 10px;
}
JavaScript
$(document).ready(function(){
var active = 0;
//Item 1
$("#item1").click(function(){
if (active == 0){
$("#ContentList1").stop().slideToggle(function() {
active = 1;
});
} else {
if (active != 1){
$("#ContentList" + active).stop().slideToggle(function() {
$("#ContentList1").stop().slideToggle(function() {
active = 1;
});
});
}
}
});
//Item 2
$("#item2").click(function(){
if (active == 0){
$("#ContentList2").stop().slideToggle(function() {
active = 2;
});
} else {
if (active != 2){
$("#ContentList" + active).stop().slideToggle(function() {
$("#ContentList2").stop().slideToggle(function() {
active = 2;
});
});
}
}
});
//Item 3
$("#item3").click(function(){
if (active == 0){
$("#ContentList3").stop().slideToggle(function() {
active = 3;
});
} else {
if (active != 3){
$("#ContentList" + active).stop().slideToggle(function() {
$("#ContentList3").stop().slideToggle(function() {
active = 3;
});
});
}
}
});
//Item 4
$("#item4").click(function(){
if (active == 0){
$("#ContentList4").stop().slideToggle(function() {
active = 4;
});
} else {
if (active != 4){
$("#ContentList" +...