我刚刚编写了这段代码来使用幻灯片将框切换为使用按钮隐藏/显示:
jQuery("#button").click(function () {
jQuery('#box').slideToggle('fast');
});
我想对此实现 cookie 以记住该框是隐藏的还是可见的。有人可以指导我吗?
最佳答案
有一个 jQuery Cookie 插件可用,它将使读取和写入 cookie 变得更加容易和方便。这是一个例子:
// if the slider is visible, set the cookie slider value to true
$.cookie('slider', 'visible', { expires: 7, path: '/' });
要读取该值,请使用以下示例:
var sliderVisible = $.cookie('slider');
更多信息可以在 jQuery Cookies Plugin Site 上找到.
关于javascript - 如何在此代码上实现 jQuery cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10764766/