Using jQuery to detect percentage of page scrolled

jquery-logo

If you need a way to detect how much percentage of user scrolled, this simple and easy script is the way I’m doing it!

	$(window).scroll(function(){
		
		var win = {
			top: $(window).scrollTop(),
			height: $(window).height()
		}, doc = {
			height: $(document).height()
		};
		
		console.log("%" + ((win.top / (doc.height - win.height)) * 100) ;
	
	});