Getting height from div using JQuery
I have two divs. One is populated by a checkbox input and some wrapped text. The other is empty.
I wanted to set the height for the second div to equal the first div. This seemed quite easy to me. Merely
- $('#divBlankReqNum').height($('#div' + lastReqID.toString()).height());
When this didn't work I entered this code
- var heightValue = $('#div' + lastReqID.toString()).height();
- alert(heightValue);
- $('#divBlankReqNum').height(heightValue);
- var heightValue = $('#divBlankReqNum').height();
- alert(heightValue);
Much to my surprise the alert showed the height of the first div to be 0.
But when I checked the JQuery web site for .height() it seemed to indicate that the height returned was the actual height of the element not contents of the style "height".
So I don't know what I am doing wrong here. I welcome any ideas.