1

我正在制作一个带有灯箱的图像滑块,但由于我找不到任何具有这两种功能的简单插件,我必须将它与 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>

4

1 回答 1

1

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

在这里你应该包括

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

并删除这个

<script type="text/javascript" src="js/jquery.js"></script>
于 2012-09-03T18:31:11.020 回答