Although I know there are many similar questions out there, please bear with me. I am not as proficient in JQuery as I am with HTML/CSS, and this is my first time using cookies. On my website, I have a green banner that should disappear when the user clicks the 'X' icon.
The JQuery code below is causing me a lot of frustration:
$(document).ready(function(){
if (!$.cookie('thecookie') || $.cookie('thecookie')==null || $.cookie('thecookie')=="") {
$("#headershadow").hide();
$("#bigx").click(function(){
$("#greenbanner").hide(1000);
$("#headershadow").show();
$.cookie('thecookie', 'true', { expires: 1, path: '/' });
});
} else {
$("#headershadow").show();
$("#greenbanner").hide();
}
});
I need to understand why this code is not working properly. The goal is for the #greenbanner
to be visible when the website loads initially, and then disappear for the day once the bigx
is clicked. I am utilizing this JQuery cookie plugin.
Any assistance in fixing this issue and making it work correctly would be greatly appreciated. I have spent quite some time trying to figure this out and I'm starting to get frustrated.