간단한 자바스크립트 시계!

안녕하세요!동영상을 보고 싶다면:
구독 잊지 마세요!
코드는 다음과 같습니다.


<!DOCTYPE html>
<html>
<head>
    <title>JS Clock</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Montserrat+Alternates:wght@300&display=swap" rel="stylesheet">
<style>
* {
    color: white;
    margin: 0;
    font-family: 'Montserrat Alternates', sans-serif;
}
p {
    font-size: 200px;
    position: absolute;
    color: #9999ff;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-shadow: 0px 0px 200px darkblue;
}
</style>
</head>
<body>
<p id="clock"></p>


<script>
setInterval(displayclock, 500);
function displayclock() {
    var time = new Date();
    var hrs = time.getHours();
    var min = time.getMinutes();
    var sec = time.getSeconds();

    document.getElementById('clock').innerHTML = hrs + ":" + min + ":" + sec;
}
</script>
</body>
</html>

좋은 웹페이지 즐겨찾기