delay() or timeout with stop()?

前端 未结 4 568
生来不讨喜
生来不讨喜 2020-12-14 17:47
$(\'.file a\').live(\'mouseenter\', function() {
    $(\'#download\').stop(true, true).fadeIn(\'fast\');
}).live(\'mouseleave\', function() {
    $(\'#download\').st         


        
4条回答
  •  情话喂你
    2020-12-14 18:22

    I was looking for the answer to a similar question, and I found that .animate() could also be used to handle this, and it obeys .stop()

    It would look something like this:

    $('.file a').live('mouseenter', function() {
        $('#download')
            .stop(true, true)
            .animate({opacity:0}, 1000);            // one second delay
            .animate({opacity:1}, 'fast', 'swing');
    }).live('mouseleave', function() {
        $('#download')
            .stop(true, true)
            .animate({opacity:0}, 'slow', 'swing');
    });
    

提交回复
热议问题