JSFiddle - React, Tailwind, and code Playground
HTML
<div class="box2">
<h3>Basketball</h3>
</div>
<div class="widget2" style="display: block; ">
<div class="widget">
<div class="box">
<h3>Australia</h3>
</div>
</div>
</div>
CSS
div.box2 {
margin-bottom: 1px;
}
div.box2 h3 {
padding: 8px;
margin-bottom: 0;
background: #6EAB29 url(../img/top-navigation-active.png) repeat-x top;
border: 1px solid #DDD;
border-bottom: 0;
color: white;
position: relative;
font-size: 12px;
font-weight: bold;
cursor: pointer;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
-moz-border-radius-topleft: 3px;
-moz-border-radius-topright: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
div.box {
margin-bottom: 1px;
}
div.box h3 {
padding: 8px;
margin-bottom: 0;
background: red url(../img/top-navigation-active.png) repeat-x top;
border: 1px solid #DDD;
border-bottom: 0;
color: white;
position: relative;
font-size: 12px;
font-weight: bold;
cursor: pointer;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
-moz-border-radius-topleft: 3px;
-moz-border-radius-topright: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
JavaScript
$(document).ready(function(){
var $widget2=$(".widget2");
readCookie('widget2')==='open'? $widget2.show(): $widget2.hide();
$(".box2").toggle(function(){
$(this).next(".widget2").slideDown(200);
setCookie('widget2','open', 1);
}, function(){
$(this).next(".widget2").slideUp(200);
setCookie('widget2','close', 1);
});
$(".box").toggle(function(){
$(this).next(".inner").slideDown(200);
}, function(){
$(this).next(".inner").slideUp(200);
});
});
function setCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}