67
55

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScriptでスクロールを最下部に移動する方法

Last updated at Posted at 2017-10-17

説明

JavaScriptで、非同期通信のタイミングに、スクロールを最下部に移動したかったのでメモ。

var obj = document.getElementById(targetId);
obj.scrollTop = obj.scrollHeight;

ページの最下部に移動する場合は以下で可能

var element = document.documentElement;
var bottom = element.scrollHeight - element.clientHeight;
window.scroll(0, bottom);

参考ページ

https://developer.mozilla.org/ja/docs/Web/API/Element/scrollTop
https://syncer.jp/javascript-reference/element/scrollheight

67
55
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
67
55

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?