简体   繁体   English

两种版本的jQuery正在运行,无法使“ noConflict”正常工作

[英]Two versions of jQuery running, can't get 'noConflict' to work

I am building a website for a customer and the site is using two versions of jQuery. 我正在为客户建立一个网站,该网站使用的是jQuery的两个版本。 One version is for the "Lava Lamp" navigation effect for the top site navigation links. 一种版本是顶部站点导航链接的“ Lava Lamp”导航效果。 The other version is for the "Smooth Div" image slider. 另一个版本适用于“ Smooth Div”图像滑块。 I can only get one or the other to work, never both simultaneously even when I plugged in the 'noConflict' script. 我只能使一个或另一个工作,即使插入'noConflict'脚本也不能同时工作。 I have since removed the noConflict script and re-uploaded it to the server. 从那以后,我删除了noConflict脚本并将其重新上传到服务器。

Here is the site: http://www.webexplosive.com/spokes 这是网站: http : //www.webexplosive.com/spokes

When you declare: 当您声明:

var jQuery_1_2_3 = $.noConflict(true);

It removes the $ alias for jQuery. 它将删除jQuery的$别名。 So you can't write : 所以你不能写:

$(function(){
   jQuery_1_2_3(selector).doSomething();
});

The initial $ is undefined. 初始的$是不确定的。

Needs to be: 需要是:

jQuery_1_2_3(function(){
       jQuery_1_2_3(selector).doSomething();
}); 

OR ( if want to use $ inside document.ready ): 或(如果要在document.ready使用$ ):

/* pass "$" to ready handler argemnent*/
jQuery_1_2_3(function($){
       /* can use "$" inside read now*/
       $(selector).doSomething();
}); 

The API docs have good instructions and examples API文档具有良好的说明和示例

http://api.jquery.com/jQuery.noConflict/ http://api.jquery.com/jQuery.noConflict/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM