meomike2000 Posted January 10, 2010 Share Posted January 10, 2010 i need to be able to get the height of a div.... i dont want to specify the height of the div due to the fact that as things get added to it the height will change... the width is specifed.... i tried some thing like this, var hheight = hiddendiv.style.height; but it will only return the value that i pre set for the div..... if i dont set a height it returns blank or undefined..... any help would be great, thanks in advance mike....... Quote Link to comment https://forums.phpfreaks.com/topic/187950-help-getting-height-of-a-div/ Share on other sites More sharing options...
RichardRotterdam Posted January 11, 2010 Share Posted January 11, 2010 I notice you're using the word hidden in your js. If your element is indeed hidden the height will be simply 0. <script type="text/javascript"> window.onload = function() { var hiddendiv = document.getElementById('hiddendiv'); var height = hiddendiv.offsetHeight; alert(height); } </script> <div id="hiddendiv"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ullamcorper hendrerit est, in eleifend orci volutpat eget. Integer tellus risus, mattis sed venenatis nec, faucibus a ligula. Quisque in sem eget diam semper venenatis. Sed ut est neque, imperdiet iaculis augue. Nulla lacinia eros at felis pharetra sodales interdum dolor bibendum. Integer enim nulla, tristique et mollis eu, commodo et lectus. Vivamus tempus feugiat luctus. Curabitur interdum pharetra odio vitae fringilla. Vestibulum tortor odio, eleifend nec faucibus ac, fringilla sit amet enim. Nullam blandit urna non turpis aliquet aliquam. Donec dignissim rutrum facilisis. Etiam interdum, felis et tincidunt consectetur, dui lacus convallis elit, vitae blandit massa tellus ut ipsum. Curabitur ultrices interdum tristique. Nam orci dui, ornare eu imperdiet et, varius in dui. Quisque vel ante urna, ut convallis libero. Duis sit amet mauris at felis dignissim faucibus sed id orci. Donec lorem diam, dignissim sed dignissim in, porta sed diam. </div> Quote Link to comment https://forums.phpfreaks.com/topic/187950-help-getting-height-of-a-div/#findComment-992743 Share on other sites More sharing options...
meomike2000 Posted January 11, 2010 Author Share Posted January 11, 2010 it is not hidden at this time, will deal with that later..... just need to be able to get the height...... Quote Link to comment https://forums.phpfreaks.com/topic/187950-help-getting-height-of-a-div/#findComment-992793 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.