回答編集履歴
1
ちょうせい
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
処理をまとめるならこんな感じ
|
2
2
|
|
3
|
-
|
3
|
+
※微調整しました
|
4
4
|
|
5
5
|
```javascript
|
6
6
|
|
@@ -12,15 +12,13 @@
|
|
12
12
|
|
13
13
|
[].forEach.call(document.querySelectorAll('.count'),x=>{
|
14
14
|
|
15
|
-
x.addEventListener('click',
|
15
|
+
x.addEventListener('click',()=>{
|
16
16
|
|
17
|
-
var t=e.target;
|
18
|
-
|
19
|
-
var view=
|
17
|
+
var view=x.closest('tr').querySelector('.view');
|
20
18
|
|
21
19
|
var total=document.querySelector('#total');
|
22
20
|
|
23
|
-
view.textContent=parseInt(view.textContent)+
|
21
|
+
view.textContent=parseInt(view.textContent)+x.classList.contains('up')-x.classList.contains('down')
|
24
22
|
|
25
23
|
total.textContent=[].map.call(document.querySelectorAll('.view'),x=>parseInt(x.textContent)).reduce((x,y)=>x+y);
|
26
24
|
|