# 置顶按钮
~~~
$(document).scroll(function () {
// 获取滚动高度
let scrollH = $(document).scrollTop();
// 控制显隐性
let min = 100, max = 300;
if (scrollH => min && scrollH <= max) {
$('#topping').css({opacity: (scrollH - min) / max});
}
});
function topping() {
$('html , body').animate({scrollTop: 0});
}
~~~
# 延时执行
~~~
let t;
clearTimeout(t)
t = setTimeout(function (){
console.log('执行了');
}, 1000);
~~~