<div class="hideWrap">
<a class="hideBtn">
Категории раздела
</a>
<div class="hideCont">bla bla</div>
</div>
function setCookie(a, b, c) {
if (c) {
var d = new Date();
d.setTime(d.getTime() + (c * 24 * 60 * 60 * 1000));
var e = "; expires=" + d.toGMTString()
} else var e = "";
document.cookie = a + "=" + b + e + "; path=/"
}
function getCookie(a) {
var b = a + "=";
var d = document.cookie.split(';');
for (var i = 0; i < d.length; i++) {
var c = d[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(b) == 0) return c.substring(b.length, c.length)
}
return null
}
function delCookie(a) {
setCookie(a, "", -1)
}
$('div.hideWrap a.hideBtn').each(function(i) {
var cookie = getCookie('hideBtn' + i);
if (cookie && cookie.indexOf('close') != -1) {
$(this).toggleClass('close').parents('div.hideWrap').find('div.hideCont').hide('normal'); // slow / normal / fast
};
});
$('div.hideWrap a.hideBtn').click(function() {
$(this).toggleClass('close').parents('div.hideWrap').find('div.hideCont').slideToggle('normal'); // slow / normal / fast
var hideBtn = $('div.hideWrap a.hideBtn').index($(this)),
isShow = $(this).attr('class');
setCookie('hideBtn' + hideBtn, isShow, 365);
return false;
});
.hideWrap{
text-align:center;
clear:both;
}
a.hideBtn{
display:block;
background: #DFDFDF;
cursor:pointer;
outline:none;
text-decoration:none;
}
a.hideBtn.close{
background: #C7C7C7;
}