简体   繁体   中英

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. One version is for the "Lava Lamp" navigation effect for the top site navigation links. The other version is for the "Smooth Div" image slider. I can only get one or the other to work, never both simultaneously even when I plugged in the 'noConflict' script. I have since removed the noConflict script and re-uploaded it to the server.

Here is the site: http://www.webexplosive.com/spokes

When you declare:

var jQuery_1_2_3 = $.noConflict(true);

It removes the $ alias for 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 ):

/* 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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