I am updating a src
tag attribute <img>
in javascript. After I have done this, I need to get a new parent height <div>
so that I can update the size of other elements on the page. If I get the parent property offsetHeight
right after updating the image src
, however, I get the height before the change was made. Is there a way to get the browser to display an updated page so that I can get a new height?
Repro:
<html>
<head>
<script type="text/javascript">
function changeImage(){
document.getElementById("image").src = "b.jpg";
alert(document.getElementById("parent").offsetHeight);
}
</script>
</head>
<body onclick="changeImage()">
<div id="parent">
<img id="image" src="a.jpg" />
</div>
</body>
</html>
source
share