-
Notifications
You must be signed in to change notification settings - Fork 859
/
index.html
108 lines (94 loc) · 2.5 KB
/
index.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab 9</title>
<style>
button {
margin: 3px;
}
button:hover {
cursor: pointer;
}
#first-num,
#second-num {
width: 60px;
}
output {
border: 1px solid gray;
display: block;
height: 18px;
margin-top: 5px;
padding: 5px;
width: 240px;
}
main {
width: 800px;
}
#error-btns {
column-gap: 5px;
display: flex;
flex-wrap: wrap;
margin-top: 30px;
row-gap: 5px;
}
#error-btns>* {
padding: 8px 2px;
width: 122px;
}
</style>
</head>
<body>
<main>
<form>
<fieldset>
<legend>Error Calculator</legend>
<input name="first-num" id="first-num" />
<select name="operator" id="operator">
<option>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
</select>
<input name="second-num" id="second-num" />
<button id="calculate">Calculate</button>
<br />
<output></output>
</fieldset>
</form>
<section id="error-btns">
<button>Console Log</button>
<button>Console Error</button>
<button>Console Count</button>
<button>Console Warn</button>
<button>Console Assert</button>
<button>Console Clear</button>
<button>Console Dir</button>
<button>Console dirxml</button>
<button>Console Group Start</button>
<button>Console Group End</button>
<button>Console Table</button>
<button>Start Timer</button>
<button>End Timer</button>
<button>Console Trace</button>
<button>Trigger a Global Error</button>
</section>
</main>
<script>
let form = document.querySelector('form');
form.addEventListener('submit', e => {
e.preventDefault();
let output = document.querySelector('output');
let firstNum = document.querySelector('#first-num').value;
let secondNum = document.querySelector('#second-num').value;
let operator = document.querySelector('#operator').value;
output.innerHTML = eval(`${firstNum} ${operator} ${secondNum}`);
});
let errorBtns = Array.from(document.querySelectorAll('#error-btns > button'));
// Start your code here
// You may move this JS to another file if you wish
</script>
</body>
</html>