//图片加载完成后将DIV的高度设置为图片的高度
$(function () {
var oImg = $("img[id$=imgCont]")[0];
window.setDivHeight = function () {
if (oImg.complete) {
$("div[id$=treeViewDiv]").css({
"height": oImg.height + 5 + "px"
});
clearTimeout(window.divHeight);
}
else {
window.divHeight = window.setTimeout("window.setDivHeight()", 500);
}
}
window.setDivHeight();
});
转载于:https://my.oschina.net/loveyj/blog/201782