滑动到底部

$(document).height();//文档高度
$(window).height();//是文档窗口高度
$(“div”).offset().top//是标签距离顶部高度
( w i n d o w ) . s c r o l l T o p ( ) ; / / 是 滚 动 条 高 度 和 (window).scrollTop();//是滚动条高度 和 (window).scrollTop();//(document).scrollTop()效果一样 但是$(window).scrollTop() 兼容性好
$(".footer").height();//是标签高度

$(window).height() 和 $(document).height()的区别
$(document).scrollTop() 获取垂直滚动的距离 (即当前滚动的地方的窗口顶端到整个页面顶端的距离)
( d o c u m e n t ) . s c r o l l L e f t ( ) 这 是 获 取 水 平 滚 动 条 的 距 离 要 获 取 顶 端 只 需 要 获 取 到 s c r o l l T o p ( ) = = 0 的 时 候 就 是 顶 端 了 要 获 取 底 端 只 要 获 取 s c r o l l T o p ( ) > = (document).scrollLeft() 这是获取水平滚动条的距离 要获取顶端 只需要获取到scrollTop()==0的时候 就是顶端了 要获取底端 只要获取scrollTop()>= (document).scrollLeft()scrollTop()==0scrollTop()>=(document).height()-$(window).height()
就可以知道已经滚动到底端了

注意: ( w i n d o w ) . h e i g h t ( )     和     (window).height()  和   (window).height()    (document).height()的区别
jQuery(window).height()代表了当前可见区域的大小,
jQuery(document).height()则代表了整个文档的高度,可视具体情况使用.
注意:当浏览器窗口大小改变时(如最大化或拉大窗口后) ,
jQuery(window).height() 随之改变,但是
jQuery(document).height()是不变的。

function scrollToEnd(){//滚动到底部
var h = ( d o c u m e n t ) . h e i g h t ( ) − (document).height()- (document).height()(window).height();
$(document).scrollTop(h);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值