How can I determine (using jQuery?) the height of a div? Its’ height is not defined in CSS – so it’s fluid and based on the contents.
I’ve tried $(‘#div’).height() – which returns 0.
Ideas?
EDIT: (the code)
$(document).ready(function () {
PositionBottomPicture();
});
function PositionBottomPicture() {
var parentOffset = $('#left_pane').offset();
var parentsHeight = $('#left_pane').height();
var childsTopPostion = (parentOffset.top + parentsHeight);
$('#bottom_pic').offset({ top: childsTopPostion, left: parentOffset.left });
}
CSS:
#left_pane
{
float: left;
margin-left: 27px;
position: relative;
}
where ‘left_pane’ and ‘bottom_pic’ are divs.
Thanks!
The problem is you’re probably not waiting for the div to load into the DOM.
Try something along the lines of:
Using the Document Ready tool provided by jQuery will wait till the element has been processed.