-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtipCalculator.html
More file actions
107 lines (88 loc) · 2.06 KB
/
tipCalculator.html
File metadata and controls
107 lines (88 loc) · 2.06 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tip calculator</title>
<style>
* {
box-sizing: border-box;
}
body {
background-color: #f2f2f2;
font-family: "Helvetica", sans-serif;
}
.container {
background-color: white;
max-width: 600px;
margin: 100px auto;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
border-radius: 10px;
}
h1 {
margin-top: 0;
text-align: center;
}
input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
margin: 10px 0;
width: 100%;
}
button {
background-color: #4caf50;
color: white;
padding: 10px;
border: none;
cursor: pointer;
margin: 10px 0;
width: 100%;
font-size: 18px;
text-transform: uppercase;
transition: background-color 0.2s ease;
}
button:hover {
background-color: #45a049;
}
#total {
font-size: 24px;
font-weight: bold;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>Tip Calculator</h1>
<p>Enter the bill amount and tip percentage to calculate the total.</p>
<label for="bill">Bill amount:</label>
<input type="number" id="bill">
<br/>
<label for="tip">Tip percentage:</label>
<input type="number" id="tip">
<br/>
<button id="calculate">Calculate</button>
<br/>
<label for="total">Total:</label>
<span id="total"></span>
</div>
<script>
const billE1 = document.getElementById("bill");
const tipE1 = document.getElementById("tip");
const calculateE1 = document.getElementById("calculate");
const totalE1 = document.getElementById("total");
calculateE1.addEventListener("click",( () => {
let billVal = billE1.value;
let tipVal = tipE1.value;
// console.log(billVal);
// console.log(tipVal);
const totalVal = billVal * (1+tipVal/100);
// console.log(totalVal);
totalE1.innerText = totalVal;
})
)
</script>
</body>
</html>