如何使用 JavaScript/jQuery 滾動到頁面的頂部?
示例
<html>
<body>
<script>
$("a").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
</script>
<h3>TOP OF PAGE</h3>
<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.<br>
This is demo text.
<br>
<h3>BOTTOM OF PAGE</h3>
<a href="#">Scroll up</a>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP