让我们假设 $(document).height()是1000.然后我在页面底部插入一个新的div,其中height = 100。 $(文档).height()应该是1100,但它一直向我投掷1000。
如何动态获取新的$(document).height()?
感谢!
答案 0 :(得分:1)
$(document).height()对我来说很好。
如果您使用变量来保存$(文档).height(),请确保在执行操作时更新它以在页面底部插入新div。
HTML:
<span class="click">test</span>
JS:
$(".click").click(function(){
var height = $(document).height();
console.log(height);
for(var i=0; i< 10; i++){
$(".click").append("<div>test</div>");}
});