回答編集履歴
1
sam
test
CHANGED
@@ -21,3 +21,41 @@
|
|
21
21
|
first_timeも now_timeも同様に100秒ずつずれるので
|
22
22
|
|
23
23
|
差分を取れば経過時間は変わりません
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
# sample
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```javascript
|
32
|
+
|
33
|
+
<div id="button">押す</div>
|
34
|
+
|
35
|
+
<script>
|
36
|
+
|
37
|
+
const test_bt = document.querySelector('#button');
|
38
|
+
|
39
|
+
let first_time= now_time=null;
|
40
|
+
|
41
|
+
test_bt.addEventListener("click" ,()=>{
|
42
|
+
|
43
|
+
if(!first_time){
|
44
|
+
|
45
|
+
first_time = new Date().getTime();
|
46
|
+
|
47
|
+
console.log("start");
|
48
|
+
|
49
|
+
}else{
|
50
|
+
|
51
|
+
now_time = new Date().getTime();
|
52
|
+
|
53
|
+
console.log((now_time - first_time) / 1000);
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
});
|
58
|
+
|
59
|
+
</script>
|
60
|
+
|
61
|
+
```
|