简体   繁体   中英

What am I doing wrong with this jQuery cookie?

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?

here is the live example: http://www.realcartips.com/test/modal/demo.html

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>

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

try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM