teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

調整

2021/10/26 02:49

投稿

yambejp
yambejp

スコア117908

answer CHANGED
@@ -8,4 +8,23 @@
8
8
 
9
9
  ※getElementByClassNameはファンクション名がtypo
10
10
  さらにHTMLCollectionをつかむので先頭を抜き出す必要があります。
11
- もし複数個ボタンがあるならさらに工夫が必要
11
+ もし複数個ボタンがあるならさらに工夫が必要
12
+
13
+ 全体像
14
+ ```javascript
15
+ <script>
16
+ window.addEventListener('DOMContentLoaded', ()=>{
17
+ const osuna = document.querySelector('.toukoub');
18
+ osuna.addEventListener('click',()=>{
19
+ osuna.textContent = "押すなって、、、";
20
+ });
21
+ });
22
+ </script>
23
+ <p><a href="../index.html" class="back">TOPに戻る</a></p>
24
+ <p class="title" id="title">運営からの大事なお知らせ</p>
25
+ <p class="announce">新しいお知らせが上にくるよ(゚∀゚)</p>
26
+ <input id="pass">
27
+ <button><div class="toukoub">投稿</div></button>
28
+ <p class="announce-text" id="announce"></p>
29
+ <small class="copyright">cゆーりん 2021 煽れよちゅぎちゅん作成委員会 inc.</small>
30
+ ```