Native js achieve a simple drop-down load

# Get the current height of the scroll bar
document.documentElement.scrollTop

  # Gets the height of the current window

document.documentElement.clientHeight

  # Get the entire height of the current document

document.documentElement.scrollHeight

 

Add scroll events, when the scroll bar height + height of the document window height =

or

When the scroll bar height + window height> = document height -20px, triggering load,

Create a div element, data is written out in the div element from the list in order

 

 

 final effect:

 

 Scroll down will be loaded each time new elements.

 



Guess you like

Origin www.cnblogs.com/pfeiliu/p/11884271.html