scrollTop()函数用于设置或返回当前匹配元素相对于垂直滚动条顶部的偏移

小例子:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div.d1{
height: 900px;
background: #456;
}
</style>
</head>
<body>
<div class="d1">156</div>
<script src="jquery.min.js"></script>
<script>
$(document).scroll(function(){
console.log($(document).scrollTop());
})
</script>
</body>
</html>

ele.offsetTop:ele到父容器顶部的距离

相关文章:

  • 2021-07-20
  • 2021-12-30
  • 2022-12-23
  • 2021-11-05
猜你喜欢
  • 2021-09-27
  • 2022-01-04
  • 2021-08-08
  • 2021-07-04
  • 2021-08-26
  • 2022-12-23
相关资源
相似解决方案