添加课程"有效"当自动滑动时,div容器分页,prev&下一个

时间:2015-06-25 07:02:38

标签: jquery

使用带有自定义分页的幻灯片JS(像缩略图一样的Div容器)创建了一个轮播。点击功能可以通过获取背景图像幻灯片索引值和分页值来正常工作。基于那个"活跃"类添加到" carousel-thumb - content"。

问题在这里。自动滑动,prev& next - 背景幻灯片工作正常。但是"活跃"类不添加到当前可见幻灯片。任何人都可以建议如何获得" index-value"可见幻灯片并将类名添加到相同的索引值"拇指钉容器"

由于

HTML:

<div class="content--carousel">
 <div class="slidesjs-container">
  <div class="slides-item slidesjs-slide" slidesjs-index="0">
    <a href="#">
        <div class="textbox">
            <h1>Architecto, placeat, saepe, delectus.</h1>
            <p>Tenetur, quos, quod inventore animi similique voluptas maiores corrupti sit
                explicabo laudantium delectus cum nihil assumenda?</p>
        </div>
        <img src="http://placehold.it/960x400" />
    </a>
  </div>
  <div class="slides-item slidesjs-slide" slidesjs-index="1">
    <a href="#">
        <div class="textbox">
            <h1>Architecto, placeat, saepe, delectus.</h1>
            <p>Tenetur, quos, quod inventore animi similique voluptas maiores corrupti sit
                explicabo laudantium delectus cum nihil assumenda?</p>
        </div>
        <img src="http://placehold.it/960x400" />
    </a>
   </div>
  </div>
</div>

<div class="carousel-thumb">
  <div class="carousel-thumb--content active">
    <a href="#" class="custom-item" data-item="0">
     <div class="carousel-thumb--image">
        <img src="http://placehold.it/63x63">
     </div>
     <div class="carousel-thumb--text">
        <div class="carousel-thumb--title">Lorem ipsum dolor</div>
        <div class="carousel-thumb--desc">Ut fringilla augue eget quam lacinia</div>
     </div>
    </a>
  </div>

  <div class="carousel-thumb--content">
   <a href="#" class="custom-item" data-item="1">
    <div class="carousel-thumb--image">
        <img src="http://placehold.it/63x63">
    </div>
    <div class="carousel-thumb--text">
        <div class="carousel-thumb--title">Lorem ipsum dolor</div>
        <div class="carousel-thumb--desc">Ut fringilla augue eget quam lacinia</div>
    </div>
   </a>
  </div>
</div>

JS:

$('.custom-item').click(function(e){
 e.preventDefault();
 $('.carousel-thumb--content').removeClass('active');
 $(this).parent().addClass('active');
 $('a[data-slidesjs-item=\'' + $(this).attr('data-item') + '\']').trigger('click');
});

0 个答案:

没有答案