【问题标题】:How to make these 2 jquery plugin work?如何使这 2 个 jquery 插件工作?
【发布时间】:2012-08-28 10:40:24
【问题描述】:

我正在制作一个带有灯箱的图像滑块,但由于我找不到任何具有这两种功能的简单插件,我必须将它与 2 个 jquery 插件混合使用,但它永远无法工作。 我可以在同一页面上使用两个 jquery 插件吗?

这是我的 html 代码:

<script src="js/jquery.min.js"></script>
    <script src="js/jquery.colorbox.js"></script>

    <script>
        $(document).ready(function(){

            $(".slider").colorbox({rel:'slider', slideshow:true});

            $(".callbacks").colorbox({
                onOpen:function(){ alert('onOpen: colorbox is about to open'); },
                onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
                onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
                onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
                onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
            });

            //Example of preserving a JavaScript event for inline calls.
            $("#click").click(function(){ 
                $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
                return false;
            });
        });

    </script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/easySlider1.5.js"></script>
<script type="text/javascript">
    $(document).ready(function(){   
        $("#slider").easySlider({
            auto: true,
            continuous: true 
        });
    }); 

</script>

<div id="container">

<div id="header"></div>

<div id="content">

<div id="slider">
        <ul>                
            <li><a class="slider" href="images/01.jpg"><img src="images/01.jpg" alt="Css Template Preview" /></a></li>
            <li><a class="slider" href="images/02.jpg"><img src="images/02.jpg" alt="Css Template Preview" /></a></li>
            <li><a  class="slider"href="images/03.jpg"><img src="images/03.jpg" alt="Css Template Preview" /></a></li>
            <li><a class="slider" href="images/04.jpg"><img src="images/04.jpg" alt="Css Template Preview" /></a></li>
            <li><a  class="slider"href="images/05.jpg"><img src="images/05.jpg" alt="Css Template Preview" /></a></li>          
        </ul>
    </div>

【问题讨论】:

    标签: javascript jquery image slider lightbox


    【解决方案1】:

    它不起作用的原因不是因为您包含了两个 jquery 插件。 但是因为你已经包含了两次 jquery 文件。删除一个就可以了

    这里你应该包括

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

    并删除它

    <script type="text/javascript" src="js/jquery.js"></script>
    

    【讨论】:

      猜你喜欢
      • 2013-02-06
      • 1970-01-01
      • 1970-01-01
      • 2014-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多