forked from mazipan/hello-open-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vidhijain.js
43 lines (43 loc) · 1.52 KB
/
vidhijain.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using change Event for Radio Buttons</title>
</head>
<body>
<h3>Choose the one you like</h3>
<input type="radio" id="happy" name="status">Be Happy with what you have</br>
<input type="radio" id="excited" name="status">Be Excited about what you want</br>
<input type="radio" id="sad" name="status">Don't be Sad </br>
<input type="radio" id="angry" name="status">Anger is your biggest enemy</br>
<input type="radio" id="none" name="status">That's great</br>
<p id="show"></p>
<script>
let show = document.querySelector('#show');
document.body.addEventListener('change', function (e) {
let target = e.target;
let display_msg;
switch (target.id) {
case 'happy':
display_msg = 'You are happy';
break;
case 'excited':
display_msg = 'You are excited';
break;
case 'sad':
display_msg = 'You are sad';
break;
case 'angry':
display_msg = 'You are angry';
break;
case 'none':
display_msg = 'none';
break;
}
show.textContent = display_msg;
});
yarn run lint --fix
</script>
</body>
</html>