Skip to content Skip to sidebar Skip to footer

Keep Toggle State On Divs Using Cookie.js After Page Refresh

I have a simple code which allows me to toggle betwen two divs which are wraps for two sub navigations (#sub-nav-wrap is the alternative nav). They are fixed to the bottom of the b

Solution 1:

you're almost done everything right only have written a lot of superfluous :)

$(function(){
    if($.cookie('submin_visible') == 'true') {
        $('#sub-nav-wrapmin').show();
        $('#sub-nav-wrap').hide();
    } else {
        $('#sub-nav-wrapmin').hide();
        $('#sub-nav-wrap').show();
    }

    $('.button').click(function(){
        $('#sub-nav-wrapmin').toggle();
        $('#sub-nav-wrap').toggle();

        var isVisible = $('#sub-nav-wrapmin').is(':visible').toString();
        $.cookie('submin_visible', isVisible);
    });
});

Post a Comment for "Keep Toggle State On Divs Using Cookie.js After Page Refresh"