JQuery Click Event Cookie

时间:2012-12-02 21:00:42

标签: jquery cookies

我试图让弹出框每24小时加载一次,但我不知道如何让JQuery Click事件接受/创建cookie。我是新的相对论。任何帮助将不胜感激!

<link rel="stylesheet" href="colorbox.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="./colorbox/jquery.colorbox.js"></script>
    <script>
        $(document).ready(function(){
            $(".ajax").colorbox();
        });
    </script>
    <script>
        $(document).ready(function() { $('.ajax').click(); });
        // Create a cookie
        $.cookie('the_cookie', 'the_value');

        // Create expiring cookie, 7 days from then:
        $.cookie('the_cookie', 'the_value', { expires: 1 });

        // Read a cookie
        $.cookie('the_cookie'); // => 'the_value'
        $.cookie('not_existing'); // => null

        // EDIT
        // Attaching to a button click (jQuery 1.7+) and set cookie
        $("#ajax").on("click", function () {
            $.cookie('the_cookie', 'the_value', { expires: 1 });
        });

        // Attaching to a button click (jQuery < 1.7) and set cookie
        $("#ajax").click(function () {
            $.cookie('the_cookie', 'the_value', { expires: 1 });
        });
    </script>
</head>
<body>
    <p><a class='ajax' href="./content/ajax.html" title="Vote IG Top 100!"></a></p>
</body>

这是网页:

http://iconik-gaming.com/popup/

谢谢大家!

0 个答案:

没有答案