开发者

Increase DIV height after replacing its HTML using AJAX

I have a div element with a certain id, and I make an AJAX call to get some data and replace the HTML of that div element with the new data.

However, the trouble is that, the height of my container does not increase even after the addition of the new HTML element within that DIV. How can 开发者_如何学运维I get the height to increase.

Thanks.


if the div is of fixed height, you can simply remove the css attribute of height, and it should take care of it.

otherwise, you can go the good 'ol fashioned:

$("#div").css("height", number + 'px');


either you set the height you want using:

$('your div selector').height(the value you want);

or don't give it a height at all and all of it parents and then it will expand automatically.


$("#ID").css({"height":"auto"});

Type that in after your $.ajax() request. You can also replace "auto" with a more specific value if you fancy. The key really is just calling a CSS change after the ajax request, so the height will be modified after.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜