html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Leap Year Checker</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h2>Leap Year Checker ✨</h2>
<input type="number" id="year-input" placeholder="Enter a year...">
<button onclick="checkLeapYear()">Check</button>
<div id="result"></div>
</div>
<div class="yt">
<a href="https://youtu.be/zegxbTfZIbQ?si=VMdG8FG7KuJ05D52">Click me</a
</div>
<script src="script.js"></script>
</body>
</html>
css
css
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
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f0f0f0;
}
.container {
background: #ffffff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
text-align: center;
width: 100%;
max-width: 300px;
}
input[type="number"] {
width: 90%;
padding: 10px;
margin: 15px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
background: #007bff;
color: #fff;
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
alert("Please subscribe my channel 🙂")
function checkLeapYear() {
const year = parseInt(document.getElementById('year-input').value);
const resultDiv = document.getElementById('result');
if (isNaN(year) || year <= 0) {
resultDiv.textContent = 'Please enter a valid year!';
resultDiv.style.color = 'red';
return;
}
if ((year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0)) {
resultDiv.textContent = `✅ ${year} is a Leap Year!`;
resultDiv.style.color = 'green';
} else {
resultDiv.textContent = `❌ ${year} is NOT a Leap Year.`;
resultDiv.style.color = 'red';
}
}
BROWSER
Console
Uruchom