两个版本的Jquery冲突 [英] two version of Jquery conflict

查看:93
本文介绍了两个版本的Jquery冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此外,我注意到我的网站正在加载两个版本的jQuery

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>

除了某些菜单导航器之外,我已禁用了大多数插件,并且无法识别来自google cdn的jquery的位置.哪个插件(如果有)?或在哪个文件中?

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?

你能帮我吗

  • 理想来源(甚至是关于外观或搜索方式的一般指南)
  • 如何解决该问题,本质上是如何从google cdn删除jquery.

我一直在阅读有关非冲突模式的信息,但是当我找不到jquery google cdn时,不知道在哪里添加no冲突命令.

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.

我之所以问是因为我有种感觉,这导致我的标签页无法正常工作. 这是带有选项卡不起作用的页面 http://goo.gl/umIYu

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

-我意识到第一个脚本与第二个脚本不同.但是,来自Google CDN的Jquery ui与我的主题使用的jqueryui冲突(不知道如何定位并粘贴到此处)

-- 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)

推荐答案

尽管您的脚本没有问题,但您仍然可以尝试

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

var k=jQuery.noConflict();

并在这样编写的新JS中将$替换为k

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');
});

编辑

在JavaScript的顶部添加var k=jQuery.noConflict();并将JS中的所有$替换为j.j不过是我们创建的并执行$所执行的所有功能的新jQuery对象,但是不会与页面上的任何其他jQuery文件冲突.

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..

示例: 如果有

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

它应该写成

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

使用noConflict之后.

after using the noConflict..

选项卡不起作用的另一个可能原因可能是您使用的旧版jQuery

您正在使用较高版本的jQuery UI和较低版本的jQuery,这可能是可能的原因. 尝试替换以下脚本

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>

使用

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

希望有帮助...

这篇关于两个版本的Jquery冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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