JSFiddle - React, Tailwind, and code Playground
by Beben Koben
HTML
<div class="msg_list" id="secondpane">
<p class="msg_head">TITLE1</p>
<div class="msg_body">
YOUR CONTENT1 HERE
</div>
<p class="msg_head">TITLE2</p>
<div class="msg_body">
YOUR CONTENT2 HERE
</div>
<p class="msg_head">TITLE3</p>
<div class="msg_body">
YOUR CONTENT3 HERE
</div>
</div>
</div>
CSS
.msg_list p {
font-size: 15px;
padding: 3px 5px;
font-weight:bold;
color: #ffffff;
}
.msg_list {
list-style: none;
margin: 0;
padding: 0;
width: 100%;
}
.msg_head {
padding: 5px 10px;
cursor: pointer;
position: relative;
background-color:#333;
margin:1px;
}
.msg_body {
padding: 5px 10px 15px;
background-color:#FFFFFF;
}
JavaScript
$(document).ready(function()
{
//hide the all of the element with class msg_body
$(".msg_body").hide();
//slides the element with class "msg_body" when paragraph with class "msg_head" is clicked
$("#firstpane p.msg_head").click(function()
{
$(this).next("div.msg_body").slideToggle(700).siblings("div.msg_body").slideUp("slow");
});
//slides the element with class "msg_body" when mouse is over the paragraph
$("#secondpane p.msg_head").mouseover(function()
{
$(this).next("div.msg_body").slideDown("slow").siblings("div.msg_body").slideUp("slow");
});
});