【发布时间】:2013-12-19 08:54:57
【问题描述】:
我正在构建一个 div 并将其附加到一个主 div。在执行此操作时,我需要在构建 div 并添加它之前立即获取它的高度。
例如,
<script>
$(function(){
var text = $("#ObjText").html(); // This text is dynamic
var dv = $("<div id='childDiv'>"+text+"</div>");
alert($(dv).height()); // This is getting '0' - Need to get the height of the div here.
$("#page").append(dv);
//After appending to page able to get the height of the child div
alert($("#childDiv").height());
});
</script>
在我的身体标签中,
<body>
<div id="page"></div>
</body>
请帮我解决这个问题。提前致谢。
【问题讨论】: