Cookie + Zurb Reveal

ale*_*wc_ 2 cookies jquery zurb-foundation

这个东西还是新的,所以我希望我对这个问题的描述是准确的.

我刚刚插入Zurb Reveal,并在页面加载时工作

$(document).ready(function (){
    $('#myModal').reveal();
});
Run Code Online (Sandbox Code Playgroud)

现在我如何让cookie运行,以便每个用户每天只显示一次?我不希望每次用户导航到主页时都会发生此弹出窗口.

任何帮助,将不胜感激!

Sar*_*ron 5

我无法设置开发环境

由于您已经在使用jQuery,因此可以获取jQuery Cookie插件(https://github.com/carhartl/jquery-cookie).然后你可以使用类似这样的代码:

$(document).ready(function(){
    // if the cookie doesn't exist create it and show the modal
    if ( ! $.cookie('hereToday') ) {

        // create the cookie. Set it to expire in 1 day
        $.cookie('hereToday', true, { expires: 1 });

        //call the reveal modal
        $('#myModal').reveal();
    }
});
Run Code Online (Sandbox Code Playgroud)