Skip to content

Commit a9e4a94

Browse files
committed
Fixed and enhanced display issue
1 parent 2fb48ec commit a9e4a94

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

digital-clock/index.html

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4+
45
<meta charset="UTF-8">
56
<title>Javascript Digital Clock</title>
6-
<link rel="stylesheet" href="style.css">
7+
<!--CSS link-->
8+
<link rel="stylesheet" href="style.css">
9+
710
</head>
811
<body>
12+
913
<div class="container">
10-
jjj
14+
<p id="time"></p>
1115
</div>
12-
<script src="script.js"></script>
16+
17+
<!--JavaScript Start-->
18+
<script>
19+
(function() {
20+
function addZeroBefore(v) {
21+
return +v < 10 ? "0" + +v : v;
22+
}
23+
24+
function showTime() {
25+
26+
var today = new Date();
27+
var textTime = addZeroBefore(today.getHours()) + " : " + addZeroBefore(today.getMinutes()) + " : " + addZeroBefore(today.getSeconds());
28+
29+
document.getElementById("time").innerHTML = textTime;
30+
31+
setTimeout(function() {
32+
showTime()
33+
}, 1000);
34+
}
35+
36+
showTime();
37+
})();
38+
</script>
39+
<!--JavaScript End-->
1340
</body>
1441
</html>

digital-clock/script.js

-19
This file was deleted.

0 commit comments

Comments
 (0)