-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (57 loc) · 3.44 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Calculator</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="calculator.js"></script>
<link rel="stylesheet" href="calculator.css" >
</head>
<body class="bg">
<div style="margin-top:15%; margin-left:43%;">
<table style="background-color:darkslategray; border-radius: 8px;" >
<tr><td colspan="4">
<input autofocus type="text" class="inp" name="l" id="l" pattern="[0-9]" onkeypress="return isNumberKey(event)" onkeyup="f5()" onblur="f2()"></td></tr>
<tr><td colspan="2"><input type="button" class="v btn btn-info" id="ac" value="AC" name="ac" onclick="clears()"></td>
<td><input type="button" class="b btn btn-info" id="del" value="del" name="del" ></td>
<td><input type="button" class="b btn btn-primary"id="divide" value="/" name="divide" onclick="f('/'); f5()"></td>
</tr> <tr><td><input type="button" class="b btn btn-info" id="7" value="7" name="7" onclick="f(7); f5()"></td>
<td><input type="button" class="b btn btn-info" id="8" value="8" name="8" onclick="f(8); f5()"></td>
<td><input type="button" class="b btn btn-info" id="9" value="9" name="9" onclick="f(9)" ></td>
<td><input type="button" class="b btn btn-primary" id="mult" value="*" name="mult" onclick="f('*'); f5()"></td>
</tr>
<tr><td><input type="button" class="b btn btn-info" id="4" value="4" name="4" onclick="f(4); f5()"></td>
<td><input type="button" class="b btn btn-info" id="5" value="5" name="5" onclick="f(5); f5()"></td>
<td><input type="button" class="b btn btn-info" id="6" value="6" name="6" onclick="f(6); f5()"></td>
<td><input type="button" class="b btn btn-primary" id="sub" value="-" name="sub" onclick="f('-'); f5()"></td>
</tr>
<tr><td><input type="button" class="b btn btn-info" id="1" value="1" name="1" onclick="f(1); f5()"></td>
<td><input type="button" class="b btn btn-info" id="2" value="2" name="2" onclick="f(2); f5()"></td>
<td><input type="button" class="b btn btn-info" id="3" value="3" name="3" onclick="f(3); f5()"></td>
<td><input type="button" class="b btn btn-primary" id="add" value="+" name="add" onclick="f('+'); f5()">
</tr>
<tr> <td><input type="button" class="b btn btn-info" id="0" value="0" name="0" onclick="f(0); f5()"></td>
<td><input type="button" class="b btn btn-info" id="d" value="." name="." onclick="f('.')"></td>
<td colspan="2"><input type="button" class="v btn btn-warning" id="e" value="=" name="e" onclick="f1()" ></td>
</tr>
</table>
</div>
<script>
$(function() {
$(document).on("keypress", function() {
$("#l").focus();
});
$("#l").keyup(function(event) {
if (event.keyCode === 13) {
$("#e").click();
}
});
$("#del").click(function(){
var str = $("#l").val();
$("#l").val(str.substring(0, str.length - 1));
});
});</script></body></html>