jQuery scrollTop() 方法

jQuery 教程 · 2019-03-27 18:58:26

实例

返回 <div> 元素的垂直滚动条位置:

$("button").click(function(){ alert($("div").scrollTop()); });

定义和用法

scrollTop() 方法设置或返回被选元素的垂直滚动条位置。

提示:当滚动条位于最顶部时,位置是 0。

当用于返回位置时:
该方法返回第一个匹配元素的滚动条的垂直位置。

当用于设置位置时:
该方法设置所有匹配元素的滚动条的垂直位置。

语法

返回垂直滚动条位置:

  
    $(selector).scrollTop()

设置垂直滚动条位置:

  
    $(selector).scrollTop(position)

参数 描述
position 规定以像素为单位的垂直滚动条位置。

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

ANSI Common Lisp

ANSI Common Lisp

Paul Graham / Prentice Hall / 1995-11-12 / USD 116.40

For use as a core text supplement in any course covering common LISP such as Artificial Intelligence or Concepts of Programming Languages. Teaching students new and more powerful ways of thinking abo......一起来看看 《ANSI Common Lisp》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具