0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【jQuery】時間を取得してHTMLに表示させる

0
Last updated at Posted at 2020-02-29
index_2.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="js/jquery-3.4.1.min.js"></script>
</head>
<body>
  <div id="label"></div>
  
  <script>
    const date = new Date();
    const hour = date.getHours();
    const minute = date.getMinutes();
    const second = date.getSeconds();
    const label = `今の時刻は${hour}${minute}${second}秒です`;
    // document.querySelector('#label').innerHTML = label;

    const write = () => {
      document.querySelector('#label').innerHTML = label;
    }
    write();

    // コンソールに表示させたい場合
    // console.log(label);
  </script>
</body>
</html>
0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?