首页
IT
登录
6mi
u
盘
搜
搜 索
IT
Back Top ②(回到顶部)
Back Top ②(回到顶部)
xiaoxiao
2026-08-03
4
<
script
>
$(
function
()
{
$.fn.manhuatoTop =
function
(options)
{
var
defaults = { showHeight :
200
, speed :
1000
};
var
options = $.extend(defaults,options);
//从两个对象中获取参数
var
$toTop = $(
this
);
var
$top = $(
"#goto-top"
); $toTop.scroll(
function
()
{
var
scrolltop=$(
this
).scrollTop();
if
(scrolltop>=options.showHeight){ $top.fadeIn(); }
else
{ $top.fadeOut(); } }); $top.click(
function
()
{
$(
"html,body"
).animate({scrollTop:
0
}, options.speed); }); } }); $(
function
()
{
$(window).manhuatoTop({ showHeight :
200
,
//小于此高度不显示按钮
speed :
1000
//回到顶部的动画速度
}); });
</
script
>
转载请注明原文地址: https://ju.6miu.com/read-1310807.html
最新回复
(
0
)