window.addEventListener('scroll',this.handleScroll,true) function handleScroll(){ let scrollTop = document.body.scrollTop || document.documentElement.scrollTop; document.getElementById('p').innerHTML = scrollTop }