Get height of DIV and it's content with JQuery

Posted by user1012403 on Stack Overflow See other posts from Stack Overflow or by user1012403
Published on 2012-04-15T17:24:28Z Indexed on 2012/04/15 17:29 UTC
Read the original article Hit count: 137

Filed under:
|
|
|

I have a div which contains several elements:

<div class="menuItem designMenu" id="dMenu">
                <ul class="menuList menu">
                <li class="menuHeader">Design</li>
                <li class="projectHeader">Mother</li>
                <li class="projectBody">Some text here</li>
                <li class="more">More</li>
                </ul>
            </div>

I need to get the height of the dMenu items that I can animate it upwards, including all the content inside. My Javascript currently:

var designHeight = $("#dMenu").height();

Returns nothing.

I've tried offsetHeight, scrollHeight, and everything else Google turns up. I'm running the JQuery at the end of the body, inside a document ready function.

The reason to get the height to animate, instead of doing it manually, is that a: I'd like to learn how and b: I don't yet know how many items will be int he div.

Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery