-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCal.html
More file actions
44 lines (39 loc) · 1.41 KB
/
Copy pathCal.html
File metadata and controls
44 lines (39 loc) · 1.41 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
</head>
<body>
<input type="text" id="tx1">
<input type="text" id="tx2">
<button onclick="add()"><h1>+</h1></button>
<button onclick="sub()"><h1>-</h1></button>
<button onclick="mul()"><h1>*</h1></button>
<button onmouseover="div()"><h1>/</h1></button>
<h1 id="out"></h1>
<script>
function add(){
let a =parseInt(document.getElementById('tx1').value)
let b =parseInt(document.getElementById('tx2').value)
document.getElementById('out').innerHTML = a+b
}
function sub(){
let a =parseInt(document.getElementById('tx1').value)
let b =parseInt(document.getElementById('tx2').value)
document.getElementById('out').innerHTML = a-b
}
function mul(){
let a =parseInt(document.getElementById('tx1').value)
let b =parseInt(document.getElementById('tx2').value)
document.getElementById('out').innerHTML = a*b
}
function div(){
let a =parseInt(document.getElementById('tx1').value)
let b =parseInt(document.getElementById('tx2').value)
document.getElementById('out').innerHTML = a/b
}
</script>
</body>
</html>