I’m trying to make a script that calculates the height of a div ‘id’ and returns the same value as margin-top. But this doesn’t do it. What’s wrong?
<script language="text/javascript">
var height = document.getElementById('id').innerHeight;
document.getElementById('id').style.marginTop = height + 'px';
</script>
Thanks in advance!
Try;
Here is a live demo.