continuous scrollTop amount in jQuery

by Faisal Khan Janjua

HTML

<div class="heightFul"></div>

CSS

.heightFul{
  width:100%;
  height:2000px;
}
p{
  margin:0;
  padding:0;
  font-size: 36px;
  position:fixed; 
  left:0; 
  top:0; 
  color:#333;
}

JavaScript

jQuery(document).ready(function(){
  if(jQuery('#scrollPosition').length<1){
    jQuery('body').prepend('<p id="scrollPosition"></p>');
  }
  jQuery(window).on('scroll', function() {
    jQuery('#scrollPosition').text(jQuery(window).scrollTop());
  });
});