的HTML:

<ul class="bxslider">
    <li><img src="image.jpg" alt="" /></li>
    <li><img src="image.jpg" alt="" /></li>
    <li><img src="image.jpg" alt="" /></li>
</ul>
<a id="selected" href="#">details</a>

我用bxslider,我想,如果最后的imageactive a#selected都会有一类.select这是可能的

样本: http//jsfiddle.net/NXzcx/83/

js

$('.bxslider').bxSlider({
  auto: true,
  infiniteLoop: false,
  hideControlOnEnd: true,
});

$(document).ready(function(){
                if (slider.active.index == 0){
                $('#selected').addClass("select");
            }

            });

===============>>#1 票数:1 已采纳

onAfterSlide回调添加到bxSlider

$('.bxslider').bxSlider({
    auto: true,
    infiniteLoop: false,
    hideControlOnEnd: true,
    onAfterSlide: function (currentSlide) {
        if(currentSlide == $('.bxslider').children('li.pager').length -1) {
            $('#selected').addClass("select");
        } else {
            $('#selected').removeClass("select");
        }
    }
});

演示

  ask by jhunlio translate from so

未解决问题?本站智能推荐: