0
是否有人知道我如何在1分钟后设置cookie过期?我在代码中设置了cookie过期,但它似乎不工作......任何人都可以帮助我解决这个问题吗?写完整的代码或小提琴给我,因为我不知道代码抱歉。预先感谢您的帮助。 这里我的小提琴:http://jsfiddle.net/Garfrey/3Lzytvqy/4/JQuery Cookie在1分钟后过期
function showHide(setCookie) {
var shID = $(this).data("showhide")
, $shEl = $("#" + shID)
, $showHide = $("#" + shID + '-show')
;
if ($shEl.is(":hidden")) {
if (setCookie !== false) {
jQuery.cookie("showhide-" + shID, 1);
}
$showHide.hide();
$shEl.show();
} else {
if (setCookie !== false) {
jQuery.cookie("showhide-" + shID, 0);
}
$showHide.show();
$shEl.hide();
}
}
jQuery(document).ready(function() {
$("#example-show").on("click", showHide);
if (jQuery.cookie("showhide-" + "example") == '1') {
showHide.call($("#example-show").get(0), false);
}
});
var date = new Date();
var minutes = 1;
date.setTime(date.getTime() + (minutes * 60 * 1000));
$.cookie("example", "foo", { expires: date });
HI taesu,感谢给我这一点,你的代码是工作..但我din't知道如何与我的函数内合并。你能让我知道我需要改变合并我的功能还是让我做小提琴?非常感谢! – kafeng 2015-02-08 07:46:03