使用jquery在firefox中没有定义$ [英] $ is not defined error in firefox with jquery

查看:52
本文介绍了使用jquery在firefox中没有定义$的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查Firefox是否加载了jquery。但是我在firebug中有一个错误告诉$ is not defined。

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>
<script type="text/javascript" src="going.js"></script>

而且go.js有以下内容。

And going.js has the following.

 if ($.browser.webkit) {
    $("body").addClass("chrome"); 

}

我试过 $(文件) .ready(function(){//我的代码在这里}); ,但它给出了同样的错误。

I tried $(document).ready(function(){ // my code here });, but it gives the same error.

有人能告诉我怎么样解决这个问题?

Could anyone tell me how to fix this?

提前致谢。

更新:
http://jsbin.com/uwopi3/3/edit

推荐答案

在关闭< / body> 之前放置两个脚本,然后立即放置jQuery代码。

Place both scripts just before closing </body> and your jQuery code right after.

更新
就像我提到的,你需要在jQuery脚本之后放置你的代码。

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>

如果此问题仍然存在,您还可以使用 jQuery.browser 而不是 $。browser 并查看它是否有效。它可能是插件和jQuery脚本之间的冲突。

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.

这篇关于使用jquery在firefox中没有定义$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆