Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
173
rated 0 times [  176] [ 3]  / answers: 1 / hits: 191498  / 14 Years ago, fri, october 1, 2010, 12:00:00

I have used jQuery library to find out height of a div.



Below is my div element with attributes :



<DIV id=myDiv style=height:auto; width:78;overflow:hidden> Simple Test</DIV>


Below is my jQuery code to get height of <div>



var result = $(#myDiv).css('height');
alert(result);


After executing above statement I am getting result as auto. Actually this is I am not expecting, instead of that I want the result in px dimension.


More From » jquery

 Answers
18

Use .height() like this:



var result = $(#myDiv).height();


There's also .innerHeight() and .outerHeight() depending on exactly what you want.



You can test it here, play with the padding/margins/content to see how it changes around.


[#95446] Tuesday, September 28, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
quinlanhenryf

Total Points: 743
Total Questions: 93
Total Answers: 118

Location: Australia
Member since Sat, May 27, 2023
1 Year ago
;