2019-06-03に投稿2026-06-30に更新数秒で読む (約97語)jsで特定要素をスクロールする方法表題の通りです。 1234567891011121314// hogeクラスの最初の要素を取得するconst hoge = window.document.getElementsByClassName('hoge')[0]// 現在の横スクロール位置を取得するconst now_x = hoge.scrollLeftconsole.log('now_x: ' + now_x)// 右に100pxスクロールするhoge.scrollTo(now_x + 100, 0)// おまけ// 画面の横幅を取得するconst window_x = window.parent.screen.widthconsole.log('window_x: ' + window_x) jsで特定要素をスクロールする方法https://reon777.com/2019/06/02/scrollTo/Authorreon777Posted on2019-06-03Updated on2026-06-30#JavaScript