$ is not defined error in firefox with jquery
I check that Firefox loads jquery. However I have an error telling, "$ is not defined" in firebug.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<sc开发者_Go百科ript type="text/javascript" src="going.js"></script>
And going.js has the following.
if ($.browser.webkit) {
$("body").addClass("chrome");
}
I tried $(document).ready(function(){ // my code here });
, but it gives the same error.
Could anyone tell me how to fix this?
Thanks in advance.
Update: http://jsbin.com/uwopi3/3/edit
Place both scripts just before closing </body>
and your jQuery code right after.
UPDATE Like i mentioned you need to place your code after your jQuery scripts.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="going.js"></script>
<script>
if ($.browser.webkit) {
$("body").addClass("chrome");
}
</script>
Another thing you can do if this problem persists is use jQuery.browser
instead of $.browser
and see if it works. It may be a conflict between the plugin and jQuery script.
精彩评论