I'd like to create a form that sets a Cookie on submission, then either hide or show content on subsequent pages depending on the existence of the cookie.
I've got using the jquery.cookie.js and this code on the form:
$(document).ready(function () {
$(".button").on('click',function() {
$.cookie('showcontent', true, { expires: 7 });
});
});
And this code on the subsequent pages:
CSS
.contentA {
display: none;}
Javascript
if (!$.cookie('showcontent')) {
$( ".contentA" ).show();
$( ".contentB" ).hide();
}
HTML
<div class="contentA">
<h1>Content A</h1>
</div>
<div class="contentB">
<h1>Content B</h1>
</div>
At the moment it doesn't function, so any help would be really appreciated.