Skip to content

Commit 2b77e9d

Browse files
authored
イベントの節の課題の解答が無かったので追加 (#711)
1 parent dbc8192 commit 2b77e9d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/1-trial-session/14-events/index.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,35 @@ HTMLファイルに一工夫が必要です。空の`<div>` タグを用意し
108108

109109
</Details>
110110

111+
<Answer title="びっくり箱">
112+
```html title="index.html"
113+
<!doctype html>
114+
<html lang="ja">
115+
<head>
116+
<meta charset="utf-8" />
117+
<title>Title</title>
118+
</head>
119+
<body>
120+
<div id="greeting"></div>
121+
<button id="button">ボタン</button>
122+
<script src="./script.js"></script>
123+
</body>
124+
</html>
125+
```
126+
127+
```js title="script.js"
128+
const greetingElement = document.getElementById("greeting");
129+
const buttonElement = document.getElementById("button");
130+
131+
function onGreetingButtonClick() {
132+
greetingElement.textContent = "Hello world!!";
133+
greetingElement.style.color = "red";
134+
greetingElement.style.fontSize = "40px";
135+
}
136+
137+
buttonElement.onclick = onGreetingButtonClick;
138+
```
139+
111140
<ViewSource url={import.meta.url} path="_samples/project-jack-in-a-box/" />
141+
142+
</Answer>

0 commit comments

Comments
 (0)