在一个页面上实现多个jQuery插件 [英] Implementing multiple jQuery plugins on one page

查看:82
本文介绍了在一个页面上实现多个jQuery插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jquery的新手,我试图让多个插件在一个页面上运行。现在我正在使用一个独立工作的动画div滑块,以及页面内的动画链接。我可以禁用一个,另一个可以工作。我已经尝试过$ .noConflict();但它只是打破了两者。这是我的代码。

I am new to jquery and am trying to get multiple plugins to function on one page. Right now I am using an animated div slider that works on its own, and an animated link within page that works on its own. I can disable one and the other will work. I have already tried the $.noConflict(); but it just breaks both. Here is my code.

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

<link rel="stylesheet" type="text/css" media="screen" href="css/coda-slider.css">

<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery-ui-1.8.20.custom.min.js"></script>
<script src="js/jquery.coda-slider-3.0.js"></script>

<script>
  $(function() {
  $('#slider-id').codaSlider({
    dynamicTabsAlign: "left",
      dynamicArrows: true,
      autoSlide: true,
      slideEaseDuration: 1000,
      autoSlideInterval:8000,
      dynamicArrowsGraphical:true
  });
});

</script>

<script type="text/javascript">
$(document).ready(function() {
   $('#navcontact').localScroll({duration:800});
});
</script>

我试图使用许多其他问题,但似乎无法让它们起作用。

I have tried to use many of the other questions but cannot seem to get them to work.

请帮助

推荐答案

删除此行:

<script src="js/jquery-1.7.2.min.js"></script>

jquery库只应加载一次,无论版本是什么。如果你再次加载它,在最后一次添加它之前添加的任何插件将无法使用。

The jquery library should only be loaded once, no matter what version. If you load it again, any plugin added before it was added the last time won't be available.

由于你同时加载版本1.4和1.7,你可以想要将上面一行移到文件顶部并删除对< script src =http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min的调用.js(也未正确关闭),因为您的某些插件可能至少需要1.7版本。

Since you are loading both a version 1.4 and 1.7, you may want to move the above line to the top of the file and delete the call to <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" (which also isn't closed properly), since some of your plugins may require at least version 1.7.

这篇关于在一个页面上实现多个jQuery插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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