LoginSignup
0

More than 1 year has passed since last update.

【JavaScript】現在時刻をリアルタイムで一定時間繰り返す画面を作成せよ。(西暦から秒まで)

Posted at
<!DOCTYPE html>
<html lang="ja">
<head>
   <meta charset="UTF-8">
   <title>一定間隔で繰り返し実行</title>
   <script>
       function count_time() {
           var timer = document.getElementById('timer');
           var date = new Date();
           timer.innerHTML = date.toLocaleString();
       }
       window.onload = function() {
           // 1秒(1000ミリ秒)ごとにcount_time関数を実行
           setInterval(count_time, 1000);
       }
   </script>
</head>
<body>
   <div id="timer"></div>
</body>
</html>

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0