javascript - How to get the height of the displayed part of an element in js?
过去多啦不再A梦2017-06-12 09:30:22
0
4
738
When an element is scrolled, some or even all elements will be hidden. How to get the height of the visible part? Using clientHeight doesn't work, what should I do?
Is it true that the clientHeight is not set for the parent container, the client is set for the visible area, the offset is set for the visible area with the scroll bar, and the scroll is set for the complete area
Do you mean the staircase effect? You can see the scrolling distance in the title
$(document).ready(function(){
$(window).scroll(function(){
Use offsetHeight
Is it true that the clientHeight is not set for the parent container, the client is set for the visible area, the offset is set for the visible area with the scroll bar, and the scroll is set for the complete area
Here is an example for preview
clientHeight