0
私の例のようにクッキーを切り替える方法はありますか?私は2つのボタンを持っていましたが、1つだけを使用してトグルしたいと思います。jQueryクラスの切り替えとクッキーの値の切り替え?
$("#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");
}
ほら。私はこれを試みたと誓っていますが、私は構文が間違っているにちがいないでしょう。あまりにも長く画面を凝視していた。ありがとう! – ejay