Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: JS Cookie hide/show div #9621
    blankniki-van-stein
    Participant

    It does not work because you can only store strings in cookies. You store the string "true" instead of the boolean value true.

    Try the following code where I replaced the check with != "true".

    <script type='text/javascript'>//<![CDATA[
      $(window).load(function(){
      // if no cookie
      if ($.cookie('alert')!="true") {
          $( "#pop-up" ).show();
          $("#hide").click(function() {
              $( "#pop-up" ).slideUp( "slow" );
              // set the cookie for 24 hours
              var date = new Date();
              date.setTime(date.getTime() + 24 * 60 * 60 * 1000); 
              $.cookie('alert', "true", { expires: date });
          });
      }
      });//]]> 
    </script>
    

    A working jsfiddle: http://jsfiddle.net/bqam0qb4/1/

Viewing 1 post (of 1 total)