jQuery noConflict()问题 [英] jQuery noConflict() problem
问题描述
为了避免任何冲突,我的JS文件中的以下行在我的页面外:
var mc $ = jQuery.noConflict();
jQuery(函数($)
如果我使用mc $ for
我在Firebug和IE中遇到了一个错误,我不知道如何解决。
在开发人员完成页面加载时,在平台上注入的文件中:
$(文档).ready(函数(){
和Firebug中的错误状态:'$ is not a函数'。
这个错误只有在我做了以下更改后才会显示出来:
var mc $ = jQuery.noConflict();
通过创建mc $变量来解决开发人员的$(document)...调用,如果是这样,我不知道如何解决这个问题,如果没有,我希望有一个解决方案,将功能提供回开发者的注入文件。
谢谢!
- jQuery库№1;
- no conflict;
- jQuery库№2 。
- jQuery库№2 。
.noConflict()
可以像这样:
< script type =text / javascript> var mc $ = jQuery.noConflict();< / script>
在脚本中使用此语法之后:
MC $( '#容器')的高度();
So I'm developing on a platform that injects jQuery-1.2.6 every time when a page loads. I developed my page to use jQuery-1.4.2, so when my page loads there are 2 jQuery instances on my page.
To avoid any conflict, I've included the following line in my JS file that is outside my page:
var mc$ = jQuery.noConflict();
jQuery(function($)
Everything seems to be working if I use mc$ for where the $ was originally used.
I am getting an error in Firebug and IE that I don't know how to resolve.
Within a file that is injected on the platform when my page loads the developer has done:
$(document).ready(function() {
and the error in Firebug states: '$ is not a function'.
This error only started to show up once I made the change of:
var mc$ = jQuery.noConflict();
I'm thinking that by creating the mc$ variable that something broke with the developer's $(document)... call. If so, I don't know how to resolve this and if not I would hope there is a solution that I can put into place to provide the functionality back to the developer's injected file.
Thanks!
A call order in your <head>
section must be next:
- jQuery library №1;
- noConflict for it;
- jQuery library №2.
.noConflict()
can look like this:
<script type="text/javascript">var mc$ = jQuery.noConflict();</script>
And after use this syntax in the scripts:
mc$('#container').height();
这篇关于jQuery noConflict()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!