Bibash Adhikari Bibash Adhikari - 1 month ago 7
CSS Question

Why does jQuery return null for element height?

I faced the same problem as that is mentioned by Matt but it is little different. I am trying to get height of a div but every time I get

null
.

HTML:

<div id="main" class="box-main " style="display:block">
<div class="box_content" style="position:absolute;top:0px;bottom:0px;height:453px;width:100%;padding-left:5px;padding-bottom:2px;">
<div style="min-width:200px;min-height:41px;padding-top:8px" id="ass-1415241823647 item-97"><div class="box">
<div class="new-try item_message" title="ram"><div class="pp"><img src="images/try.jpg" class="avatar " width="40" height="40"></div>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</div>
</div>
</div>
</div>


JavaScript:

$(document).ready(function(){
alert($("#ass-1415241823647 .item_message").height());
});


I tried this too but it didn't work.

$(document).ready(function(){
alert($("#main .box_content #ass-1415241823647 .box .item_message").height());
});

Answer

ass-1415241823647 item-97 you can't have two id's remove one or try using class if u really want to

Comments