Jquery选项卡在Jcarousel中不起作用..我该如何解决这个问题?

时间:2013-11-10 00:58:12

标签: javascript jquery jcarousel jquery-tabs

基本上我想在不同的标签中添加不同的轮播...下面是我的源代码...它失败了,不显示标签和轮播..我哪里出错了...下面是我的代码,我包括jquery和HTML ..谢谢!!

    <script type="text/javascript">

jQuery(document).ready(function() {
    jQuery('.mycarousel').jcarousel();
    $( "#tabs" ).tabs();
});

</script>
</head>
<body>
    <div id="tabs">
      <ul>
        <li><a href="#tabs-1">Carousel One display First Tab</a></li>
        <li><a href="#tabs-2">Carousel Two display Second Tab</a></li>
      </ul>

    <!-- Start of First tab -->

         <div id="tabs-1">
          <ul class="mycarousel" class="jcarousel-skin-tango">
            <li><img src="http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/75/199481072_b4a0d09597_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/57/199481087_33ae73a8de_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/77/199481108_4359e6b971_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/58/199481218_264ce20da0_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/69/199481255_fdfe885f87_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/60/199480111_87d4cb3e38_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/70/229228324_08223b70fa_s.jpg" width="75" height="75" alt="" /></li>
          </ul>
    </div>

    <!-- Start of Second tab -->
    <div id="tabs-2">
          <ul class ="mycarousel" class="jcarousel-skin-tango">
            <li><img src="http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/75/199481072_b4a0d09597_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/57/199481087_33ae73a8de_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/77/199481108_4359e6b971_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/58/199481218_264ce20da0_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/69/199481255_fdfe885f87_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/60/199480111_87d4cb3e38_s.jpg" width="75" height="75" alt="" /></li>
            <li><img src="http://static.flickr.com/70/229228324_08223b70fa_s.jpg" width="75" height="75" alt="" /></li>
          </ul>
    </div>  <!-- end of second tab -->


    </div> <!-- End div of tabs -->

</body>
</html>

1 个答案:

答案 0 :(得分:1)

您有ID“mycarousel”的多个实例。请记住,ID必须是唯一的 - 如果同一页面上有多个ID,则无法预测浏览器行为,但通常jQuery只会选择第一次出现。

尝试使用:

<ul class="mycarousel jcarousel-skin-tango">...</ul>

对于你的JS,你混合了$jQuery

jQuery(document).ready(function($) {
    $('.mycarousel').jcarousel();
    $( "#tabs" ).tabs();
});