jQuery在我的页面上工作,但萤火虫说$没有定义错误。为什么以及如何避免它? [英] jQuery works on my page, but firebug says $ is not defined error. Why and how to avoid it?

查看:89
本文介绍了jQuery在我的页面上工作,但萤火虫说$没有定义错误。为什么以及如何避免它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:最后我找到了解决方案,这完全是我的假。网站上有一个iframe标签,而在外部文件中我没有包含jQuery。
但是我从你的答案中学到了很多,并且检查了我的代码很多时间。 :)
更新END。



Firebug控制台发出以下错误消息:
$未定义
ajaxlib.js()ajaxlib .js(第6行)
[break on this error] $(document).ready(function()



但jQuery在我的页面上完美运行。 b $ b我在第一个脚本标记中包含jQuery源代码(这是最常用的解决方案),所以应该加载它。



p>

 < script language =javascripttype =text / javascriptsrc =js / jquery-1.6.1.min。 js>< / script> 
< script language =javascripttype =text / javascriptsrc =js / advexpad_lib.js>< / script>
< script language =javascripttype =text / javascriptsrc =js / ajaxlib.js>< / script>
< script language =javascripttype =text / javascriptsrc = js / highlight.pack.js>< / script>


解决方案

as in;

  $(document).ready(function(){}); 

  jQuery(document).ready(function(){}); 


UPDATE: Finally I found the solution, it was totally my fake. There were an iframe tag on the site, and in the external file I didn't include jQuery. But I learned a lot from your answer and checked my code a lot of time. :) update END.

Firebug console issues the following error message: $ is not defined ajaxlib.js()ajaxlib.js (line 6) [break on this error] $(document).ready(function()

But jQuery works perfectly on my page. I include the jQuery source in the first script tag (it was the most commonly suggested solution), so it's should be loaded.

Any help appreciated.

<script language="javascript" type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript" src="js/advexpad_lib.js"></script>
<script language="javascript" type="text/javascript" src="js/ajaxlib.js"></script>
<script language="javascript" type="text/javascript" src="js/highlight.pack.js"></script>

解决方案

Try changing all $ characters with "jQuery". They are possibly conflicting with an other library you are including.

as in;

$(document).ready(function() {} );

to

jQuery(document).ready(function() {} );

这篇关于jQuery在我的页面上工作,但萤火虫说$没有定义错误。为什么以及如何避免它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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