我用这个jQuery cookie做错了什么? [英] What am I doing wrong with this jQuery cookie?

查看:74
本文介绍了我用这个jQuery cookie做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Zurb jQuery Modal脚本来弹出一个弹出框.当用户单击关闭" x时,我想设置一个cookie,以便他们在15天内不会再次看到弹出窗口.

I'm using the Zurb jQuery Modal script to bring up a popup box. when the user clicks the "close" x, I want to set a cookie so they don't see the popup again for 15 days.

由于某种原因,我无法使它正常工作,有人可以帮忙吗?

For some reason, I can't get this to work, can someone help?

这是实时示例: http://www.realcartips.com/test/modal/demo.html

这是我正在使用的jQuery代码:

And here is the jQuery code I'm using:

$(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插件

I forgot to mention I'm using the cookie jQuery plugin

推荐答案

尝试一下:

$(".close-reveal-modal").live("click",function () {
    alert("fired");
    $.cookie("rct", 1, { expires: 15, path: '/' });
}); 

这篇关于我用这个jQuery cookie做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆