JQuery版本冲突 [英] JQuery Version Conflict

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

问题描述

我正在尝试使用Nivo JQuery Slider(http://nivo.dev7studios.com/)和Scrollable Gallery(http://flowplayer.org/tools/demos/scrollable/index.html)。

I am trying to use the Nivo JQuery Slider (http://nivo.dev7studios.com/) and a Scrollable Gallery (http://flowplayer.org/tools/demos/scrollable/index.html).

现在我遇到了一个问题,基本上Nivo Slider使用这个JQuery库:

Now I have run into a problem, basically the Nivo Slider uses this JQuery Library:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> 

和Scrollable Gallery使用这一个:

and the Scrollable Gallery uses this one:

<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>

当两者都启用时,只有缩略图库可以工作(因为它的脚本导入是在nivo之后完成的) ,当启用1.42版本时,只有Nivo可以使用,当只启用1.2.5版本时,只有可滚动图库可以工作。

When both are enabled, only the thumbnail gallery works (because it's script import is done after the nivo's), when the 1.42 version is enabled only the Nivo works, and when only the 1.2.5 version is enabled only the Scrollable Gallery Works.

我该怎么办?

推荐答案

如果您不能为这两个插件使用单个jQuery文件,请使用此解决方案:

use this solution if you cannot use a single jQuery file for both the plugins:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
  var jQuery_1_4_2 = jQuery.noConflict();
</script>
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>

要使用jQuery 1.4.2,请将代码放在SEF(Self Executing Function)中使用这个:

To use jQuery 1.4.2, put the code using it in a SEF (Self Executing Function) like this:

(function($){
   //code using jQuery 1.4.2
   //here the $variable will be the jQuery object of 1.4.2
})(jQuery_1_4_2)

对于jQuery 1.2.5,您可以直接使用$ variable。

For jQuery 1.2.5, you can use $ variable directly.

更新:
根据您的评论,以下是使用它的方法。

UPDATE: Based on your comment, following is the way to use it.

如果你想使用jQuery 1.4.2,请使用jQuery_1_4_2对象

例如: jQuery_1_4_2 (#abc)。slider(选项)

If you want to use jQuery 1.4.2, use jQuery_1_4_2 object
For example: jQuery_1_4_2("#abc").slider(options)

如果你想使用jQuery 1.2.5使用$或jQuery对象

例如: $(#abc)。scrollable(options)

If you want to use jQuery 1.2.5 use $ or jQuery object
For example: $("#abc").scrollable(options)

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

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