首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

有分析过jquery源码的同鞋帮上忙

2012-09-29 
有分析过jquery源码的同鞋帮下忙关于animate方法,当我animate高度时,可以将高度的值设为hide或show.如func

有分析过jquery源码的同鞋帮下忙
关于animate方法,当我animate高度时,可以将高度的值设为hide或show.

function close()
{
a.animate({"height":"hide"}, 700, "easeOutExpo");
}

function open()
{
a.animate({"height":"show"}, 700, "easeOutExpo");
}

我想问,用字符串当值时,它是怎样工作的,它在hide之前把当前的高度保存起来了? 因为我发现如果animate height:0之后再调height:"show"是没有反应的,只能和hide成对时才会工作。

因为我现在的代码不能直接使用slideUp和slideDown,因为它在完成时把原element设为了display:none,(用hide或show作为值时也会自动设display:none),这会导致div内的flash重新加载, IE:没声音,firefox:正常,chrome:重新加载。
所以我需要知道用"show", "hide"作为值时,它记录了哪些值,我想模拟它,但最后时不设display。


[解决办法]
第一次看见这种写法。
帮忙找了下stackoverflow,可以参考下面的文章。
http://stackoverflow.com/questions/1025074/jquery-animate-hide-and-show
[解决办法]
自己记录下a的初始化高度就好了

 

JScript code
var a, height;    $(function () {        a = $("#test")        height = a.height();        alert(height)    })    function Close() {        a.animate({ "height": "0" }, 700);    }    function Open() {        a.animate({ "height": height }, 700);    } 

热点排行