回答編集履歴
1
コード追記
test
CHANGED
@@ -1 +1,33 @@
|
|
1
1
|
[scrollWidth](https://developer.mozilla.org/ja/docs/Web/API/Element/scrollWidth)で取得できます。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
コード例
|
8
|
+
|
9
|
+
```js
|
10
|
+
|
11
|
+
const buttonright = document.querySelector('.buttonright');
|
12
|
+
|
13
|
+
const buttonleft = document.querySelector('.buttonleft');
|
14
|
+
|
15
|
+
const container = document.querySelector('.container');
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
buttonright.onclick = function () {
|
20
|
+
|
21
|
+
container.scrollLeft = container.scrollWidth;
|
22
|
+
|
23
|
+
};
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
buttonleft.onclick = function () {
|
28
|
+
|
29
|
+
container.scrollLeft = 0;
|
30
|
+
|
31
|
+
};
|
32
|
+
|
33
|
+
```
|