jQuery is not defined

Posted by dole on Stack Overflow See other posts from Stack Overflow or by dole
Published on 2010-12-27T13:27:46Z Indexed on 2010/12/27 13:54 UTC
Read the original article Hit count: 216

Filed under:

Hi there,

I have to use an external js file, in which I load the jquery. My js file look like this:

    document.write('<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>');

    (function($) {
        $(document).ready(function() {
            alert('it works!!');
        });
    })(jQuery);

On the firefox console I get the "jQuery is not defined" and I think it is because the jQuery library is loaded after the $ function from my js file.

Do you have any idea about how can I fix this? If I run the script from the FF console all works fine.

© Stack Overflow or respective owner

Related posts about jQuery