欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于jQuery實(shí)現(xiàn)滾動(dòng)刷新效果

 更新時(shí)間:2017年01月09日 09:14:26   作者:Zerone1993  
這篇文章主要為大家詳細(xì)介紹了基于jQuery實(shí)現(xiàn)滾動(dòng)刷新效果,使用Ajax獲取后臺(tái)數(shù)據(jù)更新前端頁面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

Jquery實(shí)現(xiàn)簡(jiǎn)單的滾動(dòng)刷新效果:

實(shí)際情況使用Ajax獲取后臺(tái)數(shù)據(jù)更新前端頁面即可實(shí)現(xiàn)頁面滾動(dòng)刷新效果

HTML正文:

<form id="form1" runat="server">
<div style="height: 3000px; background-color: yellow;">
</div>
</form>

Javascript操作代碼:

$(document).ready(function() {

 $(window).scroll(function() {
//$(document).scrollTop() 獲取垂直滾動(dòng)的距離:最小值為0,最大值:文檔高度-可視化窗口高度
//$(document).scrollLeft() 這是獲取水平滾動(dòng)條的距離
  console.log("垂直滾動(dòng)條位置:"+$(document).scrollTop()+"--"+$(window).height());

 if ($(document).scrollTop() <= 0) {
    console.log("滾動(dòng)條已經(jīng)到達(dá)頂部為0");
  }

  /**
   *$(document).height():文檔的高度
   *$(window).height():可視域的高度:窗口的大小:根據(jù)瀏覽窗口的大小變化
   *判斷底部:文檔高度<=滾動(dòng)條垂直高度+可視窗口的高度
   * */
  if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
   console.log("滾動(dòng)條已經(jīng)到達(dá)底部為" + $(document).scrollTop());
  }
});
 });

效果:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論