2

示例:http: //jsfiddle.net/kuTLf/

代码如下所示:

<div id="main">
        <div id="slideshow" class="pics">
            <div id="nav"></div>
            <img src="http://cloud.github.com/downloads/malsup/cycle/beach1.jpg" width="200" height="200" />
            <img src="http://cloud.github.com/downloads/malsup/cycle/beach2.jpg" width="200" height="200" />
            <img src="http://cloud.github.com/downloads/malsup/cycle/beach3.jpg" width="200" height="200" />
        </div>
</div>

js:

$(function() {
    $('#slideshow').cycle({
        fx:     'turnDown',
        speed:  'fast',
        timeout: 3000,
        pager:  '#nav',
        slideExpr: 'img'
    });
});

如何将当前活动类添加到当前 img?喜欢<img class='active>

4

2 回答 2

6
$('#slideshow').cycle({
    after: function(el, next_el) {
        $(next_el).addClass('active');
    },
    before: function(el) {
        $(el).removeClass('active');
    }
});
于 2012-04-10T22:39:08.943 回答
0

这是一个快速演示,可以了解哪个是活动的。

function onAfter1(curr,next,opts) {
   currentSlide = $(".thePager a.activeSlide").html();
    if(!currentSlide) currentSlide = "1";
    $('.slideCaption').html(currentSlide + '/' + opts.slideCount);
}
于 2012-04-10T22:38:54.793 回答