如何在此JQuery字符串中的按钮上添加活动状态

时间:2011-07-26 11:45:25

标签: jquery

我刚刚关注了http://jqueryfordesigners.com/image-cross-fade-transition/的教程,需要弄清楚如何在这个JQuery字符串上添加活动状态。

enter code here

<script type="text/javascript">
<!--

$(function () {
    //$('div.fade li.active')
        //.css( {backgroundColour: "#000000"} )
        //.mouseover(function(){
        //  $(this).stop().animate({backgroundPosition:"(-20px 94px)"}, {duration:500})
        //})
        //.mouseout(function(){
        //  $(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:200, complete:function(){
        //      $(this).css({backgroundPosition: "-20px 35px"})
        //  }})
        //})
    // find the div.fade elements and hook the hover event
    $('div.fade').hover(function() {
        // on hovering over find the element we want to fade *up*
        var fade = $('> div', this);

        // if the element is currently being animated (to fadeOut)...
        if (fade.is(':animated')) {
            // ...stop the current animation, and fade it to 1 from current position
            fade.stop().fadeTo(250, 1);
        } else {
            fade.fadeIn(250);
        }
    }, function () {
        var fade = $('> div', this);
        if (fade.is(':animated')) {
            fade.stop().fadeTo(250, 0);
        } else {
            fade.fadeOut(250);
        }
    });
});

//-->
</script>

1 个答案:

答案 0 :(得分:0)

使用点击方法

$('.yourdiv').click(function(){
 // code
});