-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathindex.html
More file actions
72 lines (66 loc) · 1.92 KB
/
index.html
File metadata and controls
72 lines (66 loc) · 1.92 KB
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
<!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;
}
input[type="number"] {
width: 60px;
}
output {
border: 1px solid gray;
display: block;
height: 18px;
margin-top: 5px;
padding: 5px;
width: 240px;
}
</style>
</head>
<body>
<fieldset>
<legend>Error Calculator</legend>
<input type="number" name="first-num" id="first-num" />
<select name="operator" id="operator">
<option>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
</select>
<input type="number" name="second-num" id="second-num" />
<button id="calculate">Calculate</button>
<br />
<output></output>
</fieldset>
<section id="error-btns">
<button>Console Log Demo</button>
<button>Console Error Demo</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>
<script>
let calculateBtn = document.querySelector('#calculate');
calculateBtn.addEventListener('click', () => {
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'));
// TODO - Make buttons functional
</script>
</body>
</html>