You can use jQuery cookie for this.
Just set a cookie on hiding, showing, and then on loading, set what is shown based on any cookies. You can do this by naming cookies as follows:"display" - this.id
If you wrapped each menu using <div id="unique">, like you do with geysers (so we have a unique identifier for setting cookies), something like this should work:
$('h3').next('.g_menu').filter(function() {
return $.cookie("expanded-" + $(this).parent("[id]").attr("id"));
}).hide();
$('h3').click(function(){
$(this).toggleClass('closeit').toggleClass('openit');
var menu = $(this).next('.g_menu');
if(menu.is(':visible')) {
menu.fadeOut(50);
$.cookie("expanded-" + $(this).parent().attr("id"), true);
} else {
menu.fadeIn(980);
$.cookie("expanded-" + $(this).parent().attr("id"), null);
}
});
To do this work, wrap <h3 class="openit">Other</h3><div class="g_menu"></div>in. <div id="other"></div> You can play with the sample to see it in action here .
source
share