我在做一个简单的噩梦!
我要它:
height.
守则如下:
// function to display status content by animating the height of the status message
function slideStatus(content){
// get current height
var status_origheight = $("#status-message").height();
// insert new content
$("#status-message").html(content);
// get new height
var status_newheight = $("#status-message").height();
// set the height to the orig value, hiding overflow content
$("#status-message").height(status_origheight).css("overflow","hidden");
// animate the div to the new height
$("#status-message").animate({height:"+="+(status_newheight - status_origheight)+""}, 1000);
}当我运行它时,它似乎忽略了内容已经更改的事实,而只是使用原始的高度(因此,不做动画,因为它认为高度没有改变)。
如果可以的话请帮忙!!快把我逼疯了。
发布于 2010-09-02 16:58:48
为我工作。你的窃听器可能在别的地方..。http://jsfiddle.net/6aBfD/
更新
http://jsfiddle.net/6aBfD/3/
但那只管用一次。问题是,您依赖于一个元素来设置它自己的高度并从中读取。但是在第一次运行之后,您将高度锁定到一个特定的值。更新后的链接具有正确的工作闭合,多次单击它。我补充了以下内容:
$("#status-message")
.css("overflow","visible")
.css("height", "auto");现在,当你读到高度时,它将是自然高度。然后,稍后再设置卵子流和高度,以便将其锁定到您想要的位置。
发布于 2010-09-02 16:59:58
罗伯,
用下面的方法代替.height():
var status_origheight = $("#status-message").css('height');
https://stackoverflow.com/questions/3629274
复制相似问题