您的位置:首页 > Web前端 > JQuery

jquery 滚动条在最下面

2015-09-17 17:30 651 查看
$(document).scrollTop($(document).height());

可以实现滚动条在最下面

对应相应实际应用:

// 弹出框显示时,滚动条在最下面
$.fn.center2 = function(position) {
return this.each(function() {
var $this = $(this),
scrollTop = $(window).scrollTop(),
// $(document).height()获取页面的文档高度 $(window).height() 获取浏览器显示区域的高度 //
top = $(document).height() - $(window).height(),
left = (document.documentElement.clientWidth - $this.outerWidth()) / 2;
top = top >= 0 ? top : 0;

if (ie6 || position) {
$this.css({
"position": "absolute",
left: left,
top: top,
margin : 0
});
} else {
$this.css({
"position": "fixed",
left: "50%",
top: "50%",
margin : -$this.outerHeight() / 2 +"px 0 0 "+ (-$this.outerWidth()/ 2)+"px"
});
}
// 滚动条在最下面
$(document).scrollTop($(document).height());
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: