jquery fade and slide simultaneously

前端 未结 3 808
囚心锁ツ
囚心锁ツ 2020-12-04 21:38

I\'m trying to both slide/fade a div simultaneously on a hover, then slide/fade it out at the end of the hover, using JQuery. The slide/fade out work properly, but the slide

3条回答
  •  自闭症患者
    2020-12-04 22:17

    The answer is that once either effects activate, it takes the inline css property "display=none" off of the element. These hide effects require the display property to be set to "none". So, just rearrange the order of methods and add a css-modifier in the chain between fade and slide.

    $('#anotherDiv').hover(function() {
        $('#myDiv').stop(true, true).fadeIn({ duration: slideDuration, queue: false }).css('display', 'none').slideDown(slideDuration);    
    }, function() {
        $('#myDiv').stop(true, true).fadeOut({ duration: slideDuration, queue: false }).slideUp(slideDuration);
    });
    

提交回复
热议问题