Trigger JQuery function when passed half way down the page

前端 未结 4 1446
伪装坚强ぢ
伪装坚强ぢ 2020-12-20 04:34

Is there a way to tell if you have scrolled passed the center of the web page or in other words, when you have scrolled passed exactly half of the web page and your scrollba

4条回答
  •  失恋的感觉
    2020-12-20 05:07

    I guess you want to do something like this:

    if($(document).scrollTop() > $(document).height()/2){
       $('.pineapple-man').show();
    }
    

    where scrollTop() gets the current horizontal position and height() defines the document height.

提交回复
热议问题