2010-11-19 47 views

回答

0

这是因为你的高度设置为0是您的if检查内(这是唯一真正的第一次)位置:

// get the original height 
    if(!height){ 
    // get original height 
    height = $el.show().height(); 
    // update the height 
    $el.data("originalHeight", height); 
    // if the element was hidden, hide it again 
    if(!visible) $el.hide().css({height: 0}); 
    } 

它需要这样的外移:

// get the original height 
    if(!height){ 
    // get original height 
    height = $el.show().height(); 
    // update the height 
    $el.data("originalHeight", height); 
    } 
    // if the element was hidden, hide it again 
    if(!visible) $el.hide().css({height: 0}); 

这样,它隐藏时间适当,you can test it out here

+0

完美,谢谢! – 2010-11-19 13:16:36

0

更换

slideToggle('#results',true); // inside hideLoading() 

content.slideDown(); 
0

我觉得这部分是错误的

if(!height){ 
    // get original height 
    height = $el.show().height(); 
    // update the height 
    $el.data("originalHeight", height); 
    // if the element was hidden, hide it again 
    if(!visible) $el.hide().css({height: 0}); 
    } 

您展示元素来获得它的高度,所以它不会滑动,因为它是看得见!

您应该使用css()方法来设置position:absolute,visibility:hiddendisplay:block

反正jQuery提供方法,取代你的功能,看看上slides