我正在使用Zurb jQuery Modal腳本調出一個彈出框。當用戶點擊「關閉」x時,我想設置一個cookie,以便他們在15天內不再看到彈出窗口。我在做這個jQuery cookie有什麼問題?
由於某種原因,我無法得到這個工作,有人可以幫忙嗎?
這裏是活生生的例子: http://www.realcartips.com/test/modal/demo.html
這裏是我使用的jQuery代碼:
$(document).ready(function() {
if (!(jQuery.cookie("rct"))) {
setTimeout(function(){
$('#myModal').reveal();
}, 1000);
}
});
$(".close-reveal-modal").click(function() {
$.cookie("rct", 1, { expires: 15, path: '/' });
});
</script>
編輯:我忘了提,我使用cookie jQuery插件
我會擴大這樣說是什麼*爲*這樣做,並且如果cookie確實被設置。 – OnResolve 2012-02-11 19:51:40
你忘了提及你可能使用[cookie](https://github.com/carhartl/jquery-cookie)插件。 – elclanrs 2012-02-11 19:52:58
@Gregg try:'if(jQuery.cookie(「rct」)== null){' – mgraph 2012-02-11 19:59:49