记住jQuery隐藏或显示页面刷新和设置Jquery cookie插件

时间:2013-01-10 00:48:21

标签: jquery jquery-cookie

$(document).ready(function(){
var ScreenSizeHis = $.cookie(ScreenSizeHis);
    $("#arrow").bind('click', function(){
        $('#naviclosed').fadeIn("fast");
        $(window).unbind('resize');
    });
    $('#naviclosed').bind('click', function () {
        $('#naviclosed').fadeOut("fast");
        if ((ScreenSizeHis = $.cookie('ScreenSizeHis')) != undefined) {
            $(window).bind('resize', ScreenSize);
        }
    });
});
$(window).resize(function() {
    ScreenSize();
});
$(document).ready(function() {
 windowwidth = $(window).width();
if (windowwidth < 1040) {
    $('#naviclosed').fadeIn("fast");
}
if (windowwidth >= 1040) {
      $('#naviclosed').fadeOut("fast");
}
});
function ScreenSize()  {
  windowsize = $(window).width();
    if (windowsize < 1040) {
      $('#naviclosed').fadeIn("fast");
    }
    if (windowsize >= 1040) {
    $('#naviclosed').fadeOut("fast"); 
    }
}

好吧,在我放入cookie插件后,按钮甚至无法正常工作。

1 个答案:

答案 0 :(得分:0)

您可以通过向$.cookie提供更多参数来设置Cookie。单个参数用于检索:

//name, value, additional -- expire cookie in 30 days
$.cookie('ScreenSizeHis', ScreenSizeHis, {expires: 30});