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 3 years have passed since last update.

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

Posted at
index.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="date">
    日付:
  </div>
  <div id="time">
    時間:
  </div>
  
  <script>
    const date = new Date();
    const jpDate = date.toLocaleDateString();
    const jpTime = date.toLocaleTimeString();

    document.querySelector('#date').innerHTML += jpDate;
    document.querySelector('#time').innerHTML += jpTime;

    //consoleに表示する場合
    // console.log(jpDate);
    // console.log(jpTime);
  </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?