开发者

How might I fade + slide an element in?

I want to slide + fade an element in, when I try doing

$("ul", this).fadeIn(300).slideDown(600);

I just get the fadeIn, how can I fade while slide an eleme开发者_JAVA百科nt in?


You can use animation for this

$("ul").animate({
"height": "toggle", "opacity": "toggle" 
}, "slow");


this will slide down then fade in

insert this function somewheres

jQuery.fn.doubleHide = function(){
    return $(this).hide().css('opacity', '0');
}


jQuery.fn.slideFade = function(slide, fade){
return $(this).slideDown(slide, function () {
    $(this).fadeTo(fade, 100);
    });
}

then u can call this function like the fadeIn()

        $(this).stop(true).doubleHide().slideFade(400, 2000);


Try calling hide() on it first, either in chaining or otherwise, and swap the functions around, :

$("ul").hide().slideDown(600).fadeIn(300);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜