SetCookie()和GetCookie()都运行良好。
问题:
使条件 IF Cookie值不为NULL然后 BOX显示继续,否则为HIde。
我运行了以下代码但条件不成真。
$(document).ready(function(){
var first_name = getCookie("chat_name");
var user_id = getCookie("chat_id");
var img_src = getCookie("chat_img");
if(first_name !=="" && user_id !=="" && img_src !=="")
// if(document.cookie.length > 0)
{
$("#chat_output").show();
$("#hidebox").show();
$("#chat_store").show();
$("#chat_box").show();
}
});
对于删除Cookie,我使用了以下代码。它运行良好
document.cookie ="chat_id=''";
document.cookie ="chat_name=''";
document.cookie ="chat_img=''";
你能否告诉我如何解决这个问题。
谢谢
答案 0 :(得分:0)
if (getCookie("cookie-name")===null){ /* code to show box */ }
应该做你想要的。