当网站在单个页面上包含大量数据并且在向下浏览网站时,如果用户希望看到主要内容,即浏览器页面顶部而不滚动,则可以使用jQuery来实现。
示例:跳转到浏览器页面的顶部
GeeksforGeeks
Welcome to GeeksforGeeks
Glad to see you!!
A Computer Science portal for the geeks.
It is the complete portal for learning in Computer Science field.
GeeksforGeeks portal contain every basic to hard knowledge regarding
Computer Science field.
You can also share interview experience here to help other geeks.
It also focuses on GATE, provides notes, previous year question papers,
last minute notes, etc.
GeeksforGeeks provides opportunity for the geeks to contribute
and help other geeks.
Scroll to Top
输出 :
在点击“滚动到顶部”之前
点击“滚动到顶部”后
在上面的例子中,当我们点击“滚动到顶部”链接时,它会自动跳转到浏览器页面的顶部。