two version of Jquery conflict

2019-05-09 22:04发布

Further, I noticed that my site is loading two version of jquery

<script type="text/javascript" src="http://www.nyimexec.com/wp-includes/js/jquery/jquery.js?ver=1.7.2"></script>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js?ver=1.8.21"></script>

I have disabled most my plugins, except some menu navigator, and cannot identify where the jquery from google cdn is located. Which plugin if any? or in which file?

Can you help me

  • idenfity where it is coming from (even general guide of where to look, or how to search)
  • how to resolve that, essentially how to delete the jquery from google cdn.

I've been reading about a non-conflict mode but, don't know where to add the no conflict command when i cannot locate the jquery google cdn.

I am asking because I have a feeling it is causing my tabs not to work. here is a page with the tabs not working http://goo.gl/umIYu

-- I realized that the first script is not same as second. However, Jquery ui from google cdn is in conflict with jqueryui used by my theme (don't know how to locate that and paste here)

3条回答
姐就是有狂的资本
2楼-- · 2019-05-09 22:49

You should list the versions from largest to smallest.

Example:

<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.0/jquery-ui.min.js?ver=1.0'></script>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.0.1/jquery-ui.min.js?ver=1.0.1'></script>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.2.1/jquery-ui.min.js?ver=1.2.1'></script>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.3.0/jquery-ui.min.js?ver=1.3.0'></script>

And so on...

查看更多
倾城 Initia
3楼-- · 2019-05-09 22:52

Though there is no problem in your scripts but you still may want to try this

var k=jQuery.noConflict();

and replace the $ with k in the new JS you are writing like this

j(document).ready(function(){
     alert('hey I am not conflicting with any other jquery script');
});

EDIT

Add the var k=jQuery.noConflict(); on the top of your javascript and replace all your $ in your JS with j.. j is nothing but a new jQuery object which is created by us and performs all functions that are performed by $ but does not conflict with any other jQuery file on the page..

Example: If you have

$(document).ready(function(){
     $('#selector').click(function(){
          alert('Hi');
     });
});

it should be written like

j(document).ready(function(){
     j('#selector').click(function(){
          alert('Hi');
     });
});

after using the noConflict..

Edit-2:

One of the other possible reason for your tabs not working can be the older version of jquery you are using

You are using a higher version of jQuery UI and a lower version of jQuery, Which can be a possible reason.. Try replacing the follwing scripts

<script type="text/javascript" src="http://www.nyimexec.com/wp-includes/js/jquery/jquery.js?ver=1.7.2"></script>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js?ver=1.8.21"></script>

with

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>


<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" type="text/javascript"></script>

Hope it helps...

查看更多
Lonely孤独者°
4楼-- · 2019-05-09 23:00

The two libraries are not same. One is the jQuery and other is the jQueryUI library which can be used together without any problem.

查看更多
登录 后发表回答