> For the complete documentation index, see [llms.txt](https://antonshevchuk.gitbook.io/jquery-for-beginners/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://antonshevchuk.gitbook.io/jquery-for-beginners/50_document_manipulation/scroll.md).

# Scrollbar

And the last pair of methods I'd like to tell you about:

<table data-header-hidden><thead><tr><th width="271">method</th><th>description</th></tr></thead><tbody><tr><td><pre class="language-javascript"><code class="lang-javascript">scrollLeft()
</code></pre></td><td>returns the horizontal scroll position for the first element in the selection</td></tr><tr><td><pre class="language-javascript"><code class="lang-javascript">scrollLeft(value)
</code></pre></td><td>sets the horizontal scroll value for each element in the selection</td></tr><tr><td><pre class="language-javascript"><code class="lang-javascript">scrollTop()
</code></pre></td><td>returns the vertical scroll position for the first element in the selection</td></tr><tr><td><pre class="language-javascript"><code class="lang-javascript">scrollTop(value)
</code></pre></td><td>sets the vertical scroll value for each element in the selection</td></tr></tbody></table>

Here's how we can find out the "distance" traveled from the top of the page:

```javascript
$('html').scrollTop();
```

Or we can "jump" to the very top of the page:

```javascript
$('html').scrollTop(0);
```

The `scrollTop` and `scrollLeft` values can be animated and don't work for hidden DOM elements:

```javascript
$('html').animate({ scrollTop: '+=200px' });
```

{% embed url="<https://anton.shevchuk.name/book/code/dom.scroll.html>" %}

***

There are really a lot of methods, and I don't always remember what each one does either (especially when it comes to the wrap family), so don't bother memorizing everything listed here. The main thing is to remember that these methods exist and keep the [documentation](https://api.jquery.com/category/manipulation/) handy.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://antonshevchuk.gitbook.io/jquery-for-beginners/50_document_manipulation/scroll.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
