【发布时间】:2019-02-11 14:10:10
【问题描述】:
我想保存站点标题显示的状态。我如何使用 Jquery Cookie 保存它?
(function ($) {
// The initial load event will try and pull the cookie to see if the toggle is "open"
var openToggle = getCookie("show") || false;
if ( openToggle )
div.style.display = "block";
else
div.style.display = "none";
if ( window.location.pathname == '/' ){
// Index (home) page
div.style.display = "block";
}
// The click handler will decide whether the toggle should "show"/"hide" and set the cookie.
$('#Togglesite-header').click(function() {
var closed = $("site-header").is(":hidden");
if ( closed )
div.style.display = "block";
else
div.style.display = "none";
setCookie("show", !closed, 365 );
});
});
【问题讨论】:
-
如何代码不起作用?那些
set/getCookie函数是什么?你能分享他们的实现吗?
标签: javascript jquery jquery-cookie