Hello. I have 30 divs with the same class on the same page. When i'm pressing the title (.pull) the content is sliding up (.toggle_container). When the content is hidden and i'm pressing the title again, the content is sliding down. Also, i want to store the div state inside a cookie. I modified my original code to store the div state inside a cookie but it's not working for all the divs (pull1, toggle_container1, pull2, toggle_container2 [...]), it's working only for the first one (pull0, toggle_container0). What i'm doing wrong?
var increment = 0;
if ($.cookie('showTop') == 'collapsed') {
$(".toggle_container" + increment).hide();
}else {
$(".toggle_container" + increment).show();
};
$("a.pull" + increment).click(function () {
if ($(".toggle_container" + increment).is(":hidden")) {
$(".toggle_container" + increment).slideDown("slow");
$.cookie('showTop', 'expanded');
increment++;
} else {
$(".toggle_container" + increment).slideUp("slow");
$.cookie('showTop', 'collapsed');
increment++;
}
return false;
});