Jquery實現簡單的滾動刷新效果:
實際情況使用Ajax獲取后臺數據更新前端頁面即可實現頁面滾動刷新效果
HTML正文:
<form id="form1" runat="server"><div style="height: 3000px; background-color: yellow;"></div></form>
Javascript操作代碼:
$(document).ready(function() { $(window).scroll(function() {//$(document).scrollTop() 獲取垂直滾動的距離:最小值為0,最大值:文檔高度-可視化窗口高度//$(document).scrollLeft() 這是獲取水平滾動條的距離 console.log("垂直滾動條位置:"+$(document).scrollTop()+"--"+$(window).height()); if ($(document).scrollTop() <= 0) { console.log("滾動條已經到達頂部為0"); } /** *$(document).height():文檔的高度 *$(window).height():可視域的高度:窗口的大小:根據瀏覽窗口的大小變化 *判斷底部:文檔高度<=滾動條垂直高度+可視窗口的高度 * */ if ($(document).scrollTop() >= $(document).height() - $(window).height()) { console.log("滾動條已經到達底部為" + $(document).scrollTop()); }}); });效果:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。
新聞熱點
疑難解答