How to detect scroll position of page using jQuery How to detect scroll position of page using jQuery jquery jquery

How to detect scroll position of page using jQuery


You can extract the scroll position using jQuery's .scrollTop() method

$(window).scroll(function (event) {    var scroll = $(window).scrollTop();    // Do something});


You are looking for the window.scrollTop() function.

$(window).scroll(function() {    var height = $(window).scrollTop();    if(height  > some_number) {        // do something    }});


Check here DEMO http://jsfiddle.net/yeyene/Uhm2J/

function getData() {    $.getJSON('Get/GetData?no=1', function (responseText) {        //Load some data from the server    })};$(window).scroll(function() {   if($(window).scrollTop() + $(window).height() == $(document).height()) {       alert("bottom!");       // getData();   }});