我只是有一個可隱藏塊的菜單。爲了在訪問期間記住它們的狀態,我決定用jQuery.cookie() 我的代碼是非常基本的:jQuery.cookie:儘管代碼非常簡單,但無需更新cookie
jQuery(document).ready(function(){
$(".titre_acordeon").next().hide();
$(".titre_acordeon").each(function() {
jQuery.cookie($(this).parent().attr("id"),false, {path: "/"});
});
$(".titre_acordeon_0").next().show();
$(".titre_acordeon_0").each(function() {
jQuery.cookie($(this).parent().attr("id"),true, {path: "/"});
});
});
jQuery(document).ready(function(){
$(".titre_acordeon, .titre_acordeon_0").click(function() {
$(this).next().toggle("medium");
var id = $(this).parent().attr("id");
var valeur_id = jQuery.cookie(id);
alert(valeur_id)
if (valeur_id == true)
{
jQuery.cookie(id, false, {path: "/"});
}
else if (valeur_id == false)
{
jQuery.cookie(id, true, {path: "/"});
}
alert(jQuery.cookie(id))
});
});
「 作爲也不例外,Cookie值永遠不會改變:顯示/隱藏作品如果我通過改變「如果(valeur_id ==真)」,「如果(valeur_id)」,餅乾改變,但只有一次
我很絕望!這應該是easyyy!
THX閱讀本!
哎呀我忘了說alert(valeur_id)和alert(jQuery.cookie(id)) 總是返回相同的假或真,取決於初始值 – flop25