开发者

how can i get $(document).height() NEW value when new data has been added?

Lets suppose that $(document).height() is 1000. Then i insert a new div at the bottom of t开发者_StackOverflow中文版he page with height=100. The $(document).height() should be 1100 but it keeps throwing 1000 to me.

How can i get the new $(document).height() dynamically?

Thank!


$(document).height() works fine for me in this case.

If you're using a variable to hold the $(document).height(), make sure you update it when the action is performed to insert the new div at the bottom of the page.

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>");}
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜