javascript - how can I tell when the scroll-bar is at a certain height? -


how can tell when scroll bar @ height meaning when there amount of space between top of scroll-bar , top of scroll-bar's track?

and execute jquery code if value.

let's when space between scroll-bar's , scroll-bar's track's top 50% of current viewport height alert "50% has been reached".

element particular div, tag or body want check.

element.scrolltop - pixels hidden in top due scroll. no scroll value 0.

element.scrollheight - pixels of whole div.

element.clientheight - pixels see in browser.

var  =  element.scrolltop  ; 

will position.

var b  =  element.scrollheight - element.clientheight  ; 

will maximum value scrolltop.

var c  =  (a / b)*100  ; 

will percent of scroll [from 0 100].


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -