首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery冲突

jQuery冲突
EN

Stack Overflow用户
提问于 2010-02-13 15:20:51
回答 3查看 1.6K关注 0票数 0

我的页面上有一个wordpress插件lightbox2和一个新闻滚动器。

我的头部部分看起来像这样

代码语言:javascript
复制
<script type="text/javascript" src="wp-content/themes/soundsright/menu.js"></script>
<script type='text/javascript' src='wp-includes/js/prototype.js?ver=1.6'></script>
<script type='text/javascript' src='wp-includes/js/scriptaculous/wp-scriptaculous.js?ver=1.8.0'></script>
<script type='text/javascript' src='wp-includes/js/scriptaculous/effects.js?ver=1.8.0'></script>
<script type='text/javascript' src='wp-content/plugins/lightbox-2/lightbox.js?ver=1.8'></script>
<script type='text/javascript' src='wp-includes/js/jquery/jquery.js?ver=1.3.2'></script>

    <!-- begin lightbox scripts -->
    <script type="text/javascript">
    //<![CDATA[
    document.write('<link rel="stylesheet" href="wp-content/plugins/lightbox-2/Themes/Grey/lightbox.css" type="text/css" media="screen" />');
    //]]>
    </script>
    <!-- end lightbox scripts -->


        <!-- SwfObj Plugin version SWFOBJ_VERSION -->
        <script type="text/javascript" src="wp-content/plugins/swfobj/swfobject.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="wp-content/themes/soundsright/liscroll.js"></script>

<script type="text/javascript">
$(function(){
   $("ul#ticker01").liScroll({travelocity: 0.03});  

});

</script>

就像现在一样,新闻滚动器可以工作,但不能用灯箱插件。当我移除

代码语言:javascript
复制
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>

然后,灯箱工作,但不是新闻滚动体。

我认为删除这个jQuery参考可以解决这个问题,因为wordpress已经在这行中加载了相同版本的jQuery

代码语言:javascript
复制
<script type='text/javascript' src='wp-includes/js/jquery/jquery.js?ver=1.3.2'></script>

,我在这里做错什么了吗?

EN

回答 3

Stack Overflow用户

发布于 2010-02-13 15:25:22

我认为这将是因为function()冲突,我们最近也有类似的东西;您需要更精确地将它与jQuery匹配(基本上$引用将由prototype或其他javascripts之一拥有,因此您可以用jQuery替换它)。

代码语言:javascript
复制
jQuery(function(){

   jQuery("ul#ticker01").liScroll({travelocity: 0.03});  

});
票数 1
EN

Stack Overflow用户

发布于 2010-02-13 15:26:50

$被Prototype和jQuery使用:

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

票数 0
EN

Stack Overflow用户

发布于 2010-02-13 17:36:56

由于JQuery和Prototype都使用$符号,所以在非冲突模式下使用Jquery

代码语言:javascript
复制
   jQuery.noConflict();

   JQuery(function(){
       JQuery("ul#ticker01").liScroll({travelocity: 0.03});      
   });

并使用$作为原型

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2258019

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档