jq监控滑轮

html没写  很简单看到js举一反三添加两个id就行了 

css: 

<style type="text/css">
.guding {
position: fixed;
top: 0px;
background-color: rgba(255, 255, 255, 0.95);
z-index: 1000;
}
</style>

js: 

<script type="text/javascript">
$(document).scroll(function() {
console.log("saas");
var titl = $("#ull").offset().top;
var hide = $(document).scrollTop();
if(hide - titl >= 542) {
$("#ull2").addClass("guding");
} else {
$("#ull2").removeClass("guding");
}
});
</script>

猜你喜欢

转载自blog.csdn.net/weixin_42694072/article/details/81584455
jq