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>");}
});
精彩评论