質問編集履歴

1

JavaScriptのコードの一部を変更

2021/02/23 06:00

投稿

teddy1121
teddy1121

スコア44

test CHANGED
File without changes
test CHANGED
@@ -20,42 +20,90 @@
20
20
 
21
21
 
22
22
 
23
- ```ここに言語名を入力
23
+ ```javascript
24
24
 
25
- firebase.auth().onAuthStateChanged((user)=> {
25
+ <h1>出退勤リスト</h1>
26
26
 
27
- userName = user.displayName;
27
+ <div class = "content">
28
28
 
29
+ <form id="add-inout-form"></form>
30
+
31
+
32
+
33
+ <table border="1" id="tableMain">
34
+
35
+ <thead>
36
+
37
+ <tr>
38
+
39
+ <th>日付</th>
40
+
41
+ <th>出社</th>
42
+
43
+ <th>退社</th>
44
+
45
+ </tr>
46
+
47
+ </thead>
48
+
49
+ <tbody id="table"></tbody>
50
+
51
+ <tr>
52
+
53
+ <th><ul id="inout-list"></ul></th>
54
+
55
+ </tr>
56
+
57
+
58
+
59
+ </table>
60
+
61
+ <script type="text/javascript">
62
+
63
+
64
+
65
+ firebase.auth().onAuthStateChanged((user)=> {
66
+
67
+ userName = user.displayName;
68
+
29
- userId = user.uid;
69
+ userId = user.uid;
70
+
71
+
72
+
73
+ database.collection(userId).get().then((snapshot)=>{
74
+
75
+ snapshot.forEach((doc)=>{
76
+
77
+ console.log( doc.data() );
30
78
 
31
79
 
32
80
 
33
-
81
+ jQuery('#table').append('<tr data-rowid="1">');
34
82
 
35
- database.collection(userId).get().then((snapshot)=>{
83
+ jQuery('#table').append('<td class="timeValue">'+ doc.data().outTimeValue + '</td>');
36
84
 
37
- snapshot.forEach((doc)=>{
85
+ jQuery('#table').append('<td class="timeValue">'+ doc.data().intime + '</td>');
38
86
 
39
- console.log( doc.data() );
87
+ jQuery('#table').append('<td class="timeValue">'+ doc.data().outTime + '</td>');
40
88
 
41
-
89
+ jQuery('#table').append('<td><input type="button" value="削除">'+'削除'+'</td>');
42
90
 
43
- jQuery('#table').append('<tr data-rowid="1">');
44
-
45
- jQuery('#table').append('<td class="timeValue">'+ doc.data().outTimeValue + '</td>');
46
-
47
- jQuery('#table').append('<td class="timeValue">'+ doc.data().intime + '</td>');
48
-
49
- jQuery('#table').append('<td class="timeValue">'+ doc.data().outTime + '</td>');
50
-
51
- jQuery('#table').append('<td><input type="button" class="deleteBtn">'+'<削除>'+'</td>');
52
-
53
- jQuery('#table').append('</tr>');
54
-
55
-
56
-
57
- });
91
+ });
58
92
 
59
93
  });
60
94
 
95
+ });
96
+
97
+ </script>
98
+
99
+ </div>
100
+
101
+
102
+
103
+ <script>
104
+
105
+ table.addEventListener ('click',({target:e})=> e.classList.contains ('deleteBtn') && e.closest ('tr').remove (), false)
106
+
107
+ </script>
108
+
61
109
  ```