文章内容

2021/3/16 10:25:02,作 者: 黄兵

Jquery获取滚动条距离页面顶部的高度

下面是使用Jquery获取滚动条到页面顶部的高度:

function set_cart_styles() {
const $scroll_height = $(document).scrollTop();
if ($scroll_height > 144) {
$(".cart-header-wrapper").addClass("cart-header-wrapper-fixed");
$("header.show").css("box-shadow","none");
} else {
$(".cart-header-wrapper").removeClass("cart-header-wrapper-fixed");
$("header.show").css("box-shadow","0 2px 4px rgb(0 0 0 / 50%)");
}
}
分享到:

发表评论

评论列表