javascript - How to use jquery Cookie? -


i have simple code:

<html>     <head>         <script src="lib/jquery-1.11.0.min.js"></script>         <script>             $(document).ready(function () {                     $('.close_i').click(function(){                     $('.adsbox').hide();                     $('.open_i').show();                 });                  $('.open_i').click(function(){                     $('.adsbox').show();                     $('.open_i').hide();                 });                 });         </script>     </head>     <body>         <div class="adsbox">             <img src="as1.jpg">             <img src="as2.jpg">             <img src="as3.jpg">             <img src="as4.jpg">             <img src="as5.jpg">             <img src="as6.jpg">            <a class="close_i">close ads</a>        </div>         <a class="open_i" style="display:none;">open ads</a>    </body> </html> 

i want this: when user clicks on "close ads", there following jquery instructions:

$(document).ready(function () {         $('.close_i').click(function(){         $('.adsbox').hide();         $('.open_i').show();     });      $('.open_i').click(function(){         $('.adsbox').show();         $('.open_i').hide();     });     }); 

and cookie plugin, save adsbox status in user's browser 3 days.

my question is: how can use jquery cookie ?! i dont know explanation : jquery cookie plugin.

can give me working code?

thanks.

first have this:

$(document).ready(function () {         $('.close_i').click(function(){         $('.adsbox').hide();         $('.open_i').show();         $.cookie("disclaimer", 1, { expires : 3 });     });      $('.open_i').click(function(){         $('.adsbox').show();         $('.open_i').hide();         $.removecookie("disclaimer");     });     }); 

if closed adds, whenever enter page again adds must closed (3 days on), have add also:

$(document).ready(function () {         if ($.cookie("disclaimer")){         $('.adsbox').hide();         $('.open_i').show();     });    }); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -