-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs_task3.html
52 lines (52 loc) · 1.66 KB
/
js_task3.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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Task 3</title>
<style>
body {
display: grid;
place-content: center;
}
.box {
border-radius: 3px;
padding: 12px;
min-width: fit-content;
border: 2px solid black;
}
</style>
</head>
<body>
<div class="box">
<label for="num1">1st Number:</label>
<input type="number" name="num1" id='num1' placeholder="Enter the first number" required>
<br>
<label for="num2">2nd Number:</label>
<input type="number" name="num2" id="num2" placeholder="Enter the second number" required>
<br>
<button onclick="multiply()">Multiply</button>
<button onclick="divide()">Divide</button>
<br>
<label for="output">The result is:</label>
<br>
<p id="output">0</p>
</div>
<script>
const num1Elem = document.getElementById('num1');
const num2Elem = document.getElementById('num2');
const outputElem = document.getElementById('output');
const multiply = ()=> {
const num1 = parseInt(num1Elem.value)
const num2 = parseInt(num2Elem.value)
let res = num1 * num2;
outputElem.innerText = res;
}
const divide = ()=> {
const num1 = parseInt(num1Elem.value)
const num2 = parseInt(num2Elem.value)
let res = num1 / num2;
outputElem.innerText = res;
}
</script>
</body>
</html>