jQuery height() returns 0 on a visible div - why?

前端 未结 5 698
一个人的身影
一个人的身影 2020-12-09 07:21

I have a container (thetext1) with a set height of 360px. \"thetext1\" contains two divs - one on the left and one floated to the right - into both of which content is deli

5条回答
  •  青春惊慌失措
    2020-12-09 08:02

    You can still use $(document).ready as long as you check to see if the element is loaded first. I chose to go with

     $("_element name/id_").load(function() {
          $(this).height();
     });
    

    I originally found the solution here: http://www.fortwaynewebdevelopment.com/jquery-width-or-height-always-returns-0-fix/

    And chose to use the answer in the first response.

提交回复
热议问题