Script analysing DIV height non function

江枫思渺然 提交于 2019-12-06 12:06:22
rjosori

I tried the following which works for me. Check the id and class attributes for the div element, and make sure the content is actually greater than 600 (height) you can try adding an else statement to see your height:

$(document).ready(function(e) {
var height = $('#sidebar1').height();
var pageHeight = $(window).height();

    if ((height) > 600) {
        alert('haha');
    }

    else {
        alert(height);
    }
});


.sidebar { 
    float: right; 
    width: 190px; 
    padding-top:8px; 
}


<div id="sidebar1" class="sidebar">
    <img src="SomeContent.png" width="190" height="601" />
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!