Saving cookie for menue item
I have this code that collapses and expands the menu items. First I installed the jQuery cookie plugin. Now I need to save the value in a cookie of the top level category that is clicked.
- (function($) {
$(document).ready(function() {
$(".wpsc_top_level_categories > li:has(li)").prepend("<span class=\"CatExpander\">+</span>");
$(".wpsc_top_level_categories").css( 'cursor', 'pointer' );
$(".CatExpander").toggle(function() {
$(this).html( '-' );
}, function() {
$(this).html( '+' );
});
$(".wpsc_top_level_categories li a").click(function() {
$.cookie('NavCookie', $(this).toggleClass("CatExpanded").siblings(".CatExpander"));//added
$(this).toggleClass("CatExpanded").siblings(".CatExpander").toggle();//toggles the +
$(this).toggleClass("CatExpanded").siblings("ul").slideToggle(500);
}).eq(500).addClass("CatExpanded").end().slice(0).siblings("ul").hide();
$(".wpsc_top_level_categories > li:has(li)").hover(function () {
$(this).children("a").click(function () {
return false;
});
});
});
})(jQuery);