jQuery循环插件如何添加活动类 [英] jQuery cycle plugin how to add an active class

查看:86
本文介绍了jQuery循环插件如何添加活动类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例: 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?就像>

How can I add current active class to current img? like <img class='active>

推荐答案

$('#slideshow').cycle({
    after: function(el, next_el) {
        $(next_el).addClass('active');
    },
    before: function(el) {
        $(el).removeClass('active');
    }
});

这篇关于jQuery循环插件如何添加活动类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆