JavaScript 简单使用jQuery cookie插件来显示/隐藏通知

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript 简单使用jQuery cookie插件来显示/隐藏通知相关的知识,希望对你有一定的参考价值。

$(document).ready(function() {

  if ($.cookie('notice') == 'closed') {
    $('.notice').hide();
  } else {
    $('.notice').show();
  }
    // Show or hide on load depending on cookie 
			
  $('.notice a.close').click(function(e) {
    e.preventDefault();
    $.cookie('notice','closed');
    $(this).parent().hide();
  });
    // Simple close link to hide the notice until cookies are cleared
			
  $('a.open').click(function(e) {
    e.preventDefault();
    $.cookie('notice','open');
    $('.notice').show();
  });
    // Opener link to show the notice again

});

以上是关于JavaScript 简单使用jQuery cookie插件来显示/隐藏通知的主要内容,如果未能解决你的问题,请参考以下文章