Posted By

phil7085 on 06/26/10


Tagged

show plugin cookie hide jquery notice


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

legacye
laurentzziu


Simple use of jQuery cookie plugin to show/hide a notice


 / Published in: JavaScript
 

  1. $(document).ready(function() {
  2.  
  3. if ($.cookie('notice') == 'closed') {
  4. $('.notice').hide();
  5. } else {
  6. $('.notice').show();
  7. }
  8. // Show or hide on load depending on cookie
  9.  
  10. $('.notice a.close').click(function(e) {
  11. e.preventDefault();
  12. $.cookie('notice','closed');
  13. $(this).parent().hide();
  14. });
  15. // Simple close link to hide the notice until cookies are cleared
  16.  
  17. $('a.open').click(function(e) {
  18. e.preventDefault();
  19. $.cookie('notice','open');
  20. $('.notice').show();
  21. });
  22. // Opener link to show the notice again
  23.  
  24. });
  25.  

Report this snippet  

You need to login to post a comment.