Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript jQuery
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
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 4-Apr-13 6:46am
Edited 4-Apr-13 7:35am
(no name)498.5K
v2
Comments
Moykn at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 545
1 OriginalGriff 285
2 Shweta N Mishra 244
3 Mathew Soji 225
4 BillWoodruff 200
0 OriginalGriff 6,153
1 Sergey Alexandrovich Kryukov 5,758
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,735


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 4 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100