treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Jquery Div height not working on page load

  • Hi, I'm new to posting on forums so please let me know if I've missed anything. I've used Jquery to apply height to certain Divs. The height is basically set to 100% - 350px using this code:

    <script type="text/javascript">
    function setSizes() {
    var containerHeight = $("#wrapper").height();
    $(".fluid_height").height(containerHeight - 350);
    }
    $(window).resize(function() { setSizes(); });
    </script>


    It does not register on page load, but does register as soon as you change the browser's window size. I have not found any conflict in the CSS. The Div is part of a Jquery Div-swap, and I hope it's not down to a conflict in the js.

    Link: www.rockomole.com/geebiz_test/index (Divs are under Challenge -> Guidance and Criteria.

    Let me know if you want me to post the CSS. Thanks in advance!
  • SOLVED: this code only calls setSizes when resized. It can be called explicitly by adding

    $(document).ready( function() { setSizes(); });