我试图在每次点击后增加滚动顶部并为此编写它,但它只是第一次工作。在 x 的每个调用值是 30 时,我该如何解决?
我在 w3schools 网站上试用它,它在那里工作
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
$(function () {
$("#btncl").click(function (e) {
var x = $("div").scrollTop() + 30;
$("div").scrollTop(x);
});
});
</script>
<body>
<form id="form1" runat="server">
<div style="border: 1px solid black; height: 150px; overflow: auto">
<ul>
<li>
<img width="80px" style="margin-bottom: 5px;" height="70px" alt="" class="img_gallery"
src="Images_slider/1.jpg" />
</li>
<li>
<img width="80px" style="margin-bottom: 5px;" height="70px" alt="" class="img_gallery"
src="Images_slider/2.jpg" />
</li>
</ul>
</div>
<br>
<input type="button" value="Return the vertical position of the scrollbar" id="btncl">
</form>