【发布时间】:2011-07-29 02:21:50
【问题描述】:
有没有办法像我下面的例子那样切换 cookie?我曾经有两个按钮,但我只想使用一个来切换。
$("#text-change").click(function() {
$("body").toggleClass("large");
$(this).toggleClass("large");
// Here I want to toggle the cookie value
$.cookie("textSize", "large", {expires: 365});
$.cookie("textSize", "small", {expires: 365});
return false;
});
//then I can the check cookie throughout the site
if($.cookie("textSize") != "large") {
$("#text-smaller").addClass("disabled");
$("body").removeClass("large");
}
else {
$("#text-larger").addClass("disabled");
$("body").addClass("large");
}
【问题讨论】: