- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Baffled about scrollHeight value
For some reason I can’t figure out, the value returned by element.scrollHeight
is about 50-60px more than the actual content height. It should represent the height of the inner p
element here but is consistently higher. What am I missing?
I’ve used this kind of thing a million times before, successful as far as I’m aware of…
The scrollHeight
is logged to the console. Please take a moment to look at the actual height of the inner element through the console and compare it. Not matching up at all.
If overflow-y: scroll
is removed from .panel
, the value is suddenly correct.
Thanks in advance for any insight.
Just as strange, I get the same result when using jQuery’s .height()
on the p
element…
Seems all this stuff got somehow messed up. Yesterday outerWidth()
was all over the place too.
Either that or I’m having a major blind spot momentarily.
Edit – logging the entire element itself shows the correct amount of pixels for scrollHeight
among the list of properties.
I’ve now also added a click function (for the small custom scrollbar) which presents the correct result.
???
Wow, I’m a total idiot. Only realising that after stripping down the code:
Here the height is actually the presumed incorrect value but I’m changing the width of the element a bit later on myself in order to put the scrollbar out of view (which was the entire intention of the pen initially), with which it has a bit more space and becomes somewhat shorter.
My brain really has to get into coding again. Like in the early days, spending hours over something rather obvious. :-/
Lol, much better now.