-1

I have an html element whose height is set to 100vh and value of overflow is set to auto. So user can scroll the element to view it. What I want is to calculate actual height of the element. I am using offsetHeight property to calculate height. But is is giving me only 100vh height. But what I want is the height which will be given by offsetHeight when height of element is set to auto. How to calculate it when height of the element is set to 100vh.

2

1 Answer 1

0

I am new in this business but I use this code the calculate height of the div (whatever div that I choose It doesn't matter).

let height = document.querySelector("div").offsetHeight; if ( document.body.scrollTop > height || document.documentElement.scrollTop > height ) { //code } else { //code } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.