0

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");
            }

            });
4

1 回答 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");
        }
    }
});

演示

于 2013-04-16T03:38:03.290 回答