Return to Snippet

Revision: 27920
at June 26, 2010 23:18 by phil7085


Initial Code
$(document).ready(function() {
			
  if ($.cookie('notice') == 'closed') {
    $('a.toggle').html('Open the notice');
    $('.notice').hide();
  } else {
    $('.notice').show();
  }
    // Show or hide on load depending on cookie 
			
  $('a.toggle').click(function(e) {
    e.preventDefault()
    if ($.cookie('notice') == 'closed') {
      $('.notice').show();
      $('a.toggle').html('Close the notice');
      $.cookie('notice','open');
    } else {
      $('.notice').hide();
      $('a.toggle').html('Open the notice');
      $.cookie('notice','closed');
    }
  });
    // a more advanced link, this time to toggle the notice
		
});

Initial URL


Initial Description


Initial Title
Advanced use of jQuery cookie plugin to show/hide a notice, includes changing the HTML text of the link

Initial Tags
plugin, html, jquery

Initial Language
JavaScript