JQuery Cookie Plugin not working – jQuery is not defined

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:

Read More
$(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.

Related posts

Leave a Reply

1 comment

  1. In your source, you are including jQuery AFTER the cookie plugin (which relies on jQuery)..

    <script src="jquery.cookie.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
    

    Switch the order of these two, and it should help resolve your issues..

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
    <script src="jquery.cookie.js"></script>
    

    Also.. You seem to have a bunch or errors in your Console, fix these first and everything should work as expected.