Skip to content

Commit ad555ab

Browse files
committed
New: Simple onChange example.
1 parent 717490e commit ad555ab

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

dom/onChange.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>onChange with Select</title>
7+
<script>
8+
function handleSelectionChange(event) {
9+
const selectedOption = event.target.value;
10+
document.getElementById("selectedOption").innerText = `You selected: ${selectedOption}`;
11+
}
12+
</script>
13+
</head>
14+
<body>
15+
16+
<label for="colors">Choose a color: </label>
17+
<select id="colors" onChange="handleSelectionChange(event)">
18+
<option value="Red">Red</option>
19+
<option value="Green">Green</option>
20+
<option value="Blue">Blue</option>
21+
</select>
22+
<p id="selectedOption">You selected: </p>
23+
24+
</body>
25+
</html>
26+

0 commit comments

Comments
 (0)