Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm using scrollHeight property to find the height of a div element. It is calculating the height value a little bit additional resulting in extra blank space.

I'm using this to toggle between expand contents and contract them such that
JavaScript
if(element.height == element.scrollHeight)
{
element contracts on button click
}
else
{
element expands on button click
}

The contents of the div are a paragraph and table with four to five rows. The toggle option is working fine. But the scrollheight is calculating excessive height resulting in irregular additional spaces to each div for which i had used this concept.

Please suggest me some alternative or a solution to this issue.

Thanks in advance
Posted
Updated 4-Apr-13 6:35am
v2
Comments
Moykn 4-Apr-13 12:46pm    
does your css contains any padding or margin for the div element?
paragraphs have a default top and bottom margin.
If you are using chrome, use inspect element, maybe it could help you to se what element is causing the extra space.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900