回答編集履歴
4
kousin
test
CHANGED
@@ -37,5 +37,3 @@
|
|
37
37
|
<div id="hoge">hoge</div>
|
38
38
|
|
39
39
|
```
|
40
|
-
|
41
|
-
※更新
|
3
kousin
test
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
const t=e.target.closest('.check-btn');
|
18
18
|
|
19
|
-
if(
|
19
|
+
if(t){
|
20
20
|
|
21
21
|
console.log(t.textContent);
|
22
22
|
|
2
kousin
test
CHANGED
@@ -37,3 +37,5 @@
|
|
37
37
|
<div id="hoge">hoge</div>
|
38
38
|
|
39
39
|
```
|
40
|
+
|
41
|
+
※更新
|
1
ちょうせい
test
CHANGED
@@ -1 +1,39 @@
|
|
1
1
|
classがitemのliが該当するdomになりますが、なにか特殊なことをしたいのですか?
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
# sample
|
6
|
+
|
7
|
+
```javascript
|
8
|
+
|
9
|
+
<button class="check-btn">test1</button>
|
10
|
+
|
11
|
+
<button class="check-btn"><span>test2</span></button>
|
12
|
+
|
13
|
+
<script>
|
14
|
+
|
15
|
+
document.addEventListener('click',e=>{
|
16
|
+
|
17
|
+
const t=e.target.closest('.check-btn');
|
18
|
+
|
19
|
+
if([...document.querySelectorAll('.check-btn')].includes(t)){
|
20
|
+
|
21
|
+
console.log(t.textContent);
|
22
|
+
|
23
|
+
}
|
24
|
+
|
25
|
+
});
|
26
|
+
|
27
|
+
window.addEventListener('DOMContentLoaded',()=>{
|
28
|
+
|
29
|
+
const test=`<button class="check-btn">test3</button>\n<button class="check-btn"><span>test4</span></button>`;
|
30
|
+
|
31
|
+
document.querySelector('#hoge').insertAdjacentHTML('beforeend', test);
|
32
|
+
|
33
|
+
});
|
34
|
+
|
35
|
+
</script>
|
36
|
+
|
37
|
+
<div id="hoge">hoge</div>
|
38
|
+
|
39
|
+
```
|