/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(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 });
Comments
