<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<script src="jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
#box {
background-color: red;
height: 300px;
width: 300px;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$("#s-top-get").click(function() {
$("p").text("scrollTop()获取" + $(document).scrollTop());
});
$("#s-top-set").click(function() {
$(document).scrollTop(70);
});
});
</script>
</head>
<body>
<div id="box">
</div>
<button type="button" id="s-top-get">scrollTop()获取</button>
<button type="button" id="s-top-set">scrollTop()设置</button>
<p></p>
</body>
</html>