如何用 cookie 记住 jQuery 变量的 true 或 false 状态

How to remember jQuery variable true or false state with a cookie

我有一个按钮,单击该按钮会显示或隐藏一系列按钮。我需要做的是记住状态或变量:

is_hidden = false;

.. 如果要重新加载页面。我试过使用 jQuery.cookie 并做类似的事情:

$.cookie('is_hidden', 'false', { expires: 7, path: '/' });

不过我猜想实现这样的目标还有很长的路要走。任何帮助,将不胜感激。 Working example 如果有帮助(包括插件),请在此处找到。

使用 false、""、undefined 或 null 等虚假值来表示 false,使用 true1 等来表示 true,如下所示

 $.cookie('is_hidden', false, { expires: 7, path: '/' });
 $.cookie('is_hidden', null, { expires: 7, path: '/' });
 $.cookie('is_hidden', "", { expires: 7, path: '/' });

 $.cookie('is_hidden', true, { expires: 7, path: '/' });