-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
52 lines (52 loc) · 1.43 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
<!DOCTYPE html>
<html>
<head>
<title>信用卡回饋計算機</title>
<style>
body {
text-align: center;
}
input[type="number"] {
width: 50%;
text-align: center;
margin: 0 auto;
display: block;
font-size: 1.2em;
}
button {
width: 30%;
margin: 0 auto;
display: block;
font-size: 1.2em;
}
@media (max-width: 767px) {
input[type="number"],
button {
font-size: 1.5em;
}
}
</style>
</head>
<body>
<h1>信用卡回饋計算機</h1>
<p>輸入您的信用卡消費金額:</p>
<input type="number" id="amountSpent" />
<p>輸入回饋百分比:</p>
<input type="number" id="rewardsPercentage" />
<br /><br />
<button id="calculateButton">計算回饋</button>
<br /><br />
<p>回饋金額:</p>
<input type="number" id="rewardsAmount" readonly />
<script>
const calculateButton = document.getElementById("calculateButton");
const amountSpent = document.getElementById("amountSpent");
const rewardsPercentage = document.getElementById("rewardsPercentage");
const rewardsAmount = document.getElementById("rewardsAmount");
calculateButton.addEventListener("click", function () {
rewardsAmount.value =
(amountSpent.value * rewardsPercentage.value) / 100;
});
</script>
</body>
</html>