I realize that there are a myriad of questions like this: bear with me. I’m not as good with JQuery as I am with HTML/CSS and I’m using cookies for the first time. I’ve got this website that has a green banner that is supposed to go away when the user clicks the ‘X’.
This is the broken JQuery that’s driving me nuts:
$(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();
}
});
Essentially, I want to know why this is breaking. I need the #greenbanner
to show up the first time you load the website, and then if you click on the bigx
the #greenbanner
goes away for the day. I’m using this nifty plugin for the JQuery cookies.
Any help to get this to stop breaking and work would be fantastic. I’ve been fussing with this for far too long and I’m annoyed now.
In your source, you are including jQuery AFTER the cookie plugin (which relies on jQuery)..
Switch the order of these two, and it should help resolve your issues..
Also.. You seem to have a bunch or errors in your
Console
, fix these first and everything should work as expected.