title: jQuery Cookie hide/show div
body: <p>I am trying to set up a cookie using <a href="https://github.com/carhartl/jquery-cookie" rel="nofollow">jQuery Cookie</a> so that an alert will be displayed for new visitors and when you click the "close" button it will set a cookie and prevent the alert div from displaying. I also want to make the cookie expire after 24 hours.</p>
  
  <p>I have played around with some code and gotten it to work, however, the way I have it right now, the alert div is shown by default and only hidden once you click close. This is fine, but when the cookie exists, the alert displays for a split second before being hidden.</p>
  
  <p>How would I modify the following code so that I can hide the div by default and if the cookie doesn't exist it will be shown, but then if they hit the close button, it will generate a cookie and hide the alert for 24 hours?</p>
  
  <pre><code>if ($.cookie('alert')) $('.alert-box').hide();
  else {
      $(".close").click(function() {
          $( ".alert-box" ).slideUp( "slow", function() { });
          $.cookie('alert', true);
      });
  }
  </code></pre>