-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
122 lines (116 loc) · 3.06 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!-- <!DOCTYPE html>
<html>
<head>
<title>Konverter Suhu</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
}
input {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 20px;
font-size: 16px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Konverter Suhu</h1>
<p>Masukkan suhu dalam Fahrenheit:</p>
<input type="number" id="fahrenheit" placeholder="Contoh: 32">
<button onclick="konversiSuhu()">Konversi</button>
<p>Suhu dalam Celsius adalah: <span id="celsius"></span></p>
<script>
function konversiSuhu() {
// ini ambil nilai suhu dari input
let fahrenheit = parseFloat(document.getElementById("fahrenheit").value);
//itung suhu dalam Celsius
let celsius = (fahrenheit - 32) * 5/9;
//hasil konversi
document.getElementById("celsius").textContent = celsius.toFixed(2) + " °C";
}
</script>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html>
<head>
<title>Jam</title>
<style type="text/css">
#jam {
font-size: 40px;
padding: 20px;
margin: auto;
width: 50%;
border:5px solid black;
border-radius: 2rem;
transition: border-color 0.5s;
align-items: center;
text-align: center;
}
</style>
</head>
<body>
<div id="jam">00:00:00</div>
<script type="text/javascript">
function updatejam() {
const now = new Date();
const hours = String(now.getHours()).padStart(2,'0');
const minutes = String(now.getMinutes()).padStart(2,'0');
const seconds = String(now.getSeconds()).padStart(2,'0');
document.getElementById('jam').textContent = `${hours}:${minutes}:${seconds}`;
const borderColor = seconds % 2 === 0 ? 'red' : 'blue';
document.getElementById('jam').style.borderColor = borderColor;
}
setInterval(updatejam,1000);
updatejam();
</script>
</body>
</html> -->
<!DOCTYPE html>
<html>
<head>
<title>Daftar mobil</title>
<style type="text/css">
.genap {
color: blue;
font-weight: bold;
}
</style>
</head>
<body>
<h1>Mobil</h1>
<ul id="mobil">
<li>Actura</li>
<li>Alfa Remeo</li>
<li>Aston Martin</li>
<li>Audi</li>
<li>Bentley</li>
<li>BMW</li>
<li>Bugatti</li>
<li>Buick</li>
</ul>
<button onclick="changeEvenItems()">Klick mengubah Genap</button>
<script type="text/javascript">
function changeEvenItems(){
const listItems = document.querySelectorAll("#mobil li");
listItems.forEach((item, index) => {
if ((index + 1) % 2 === 0) {
item.classList.toggle("genap");
}
});
}
</script>
</body>
</html>