LoginSignup
0
0

More than 3 years have passed since last update.

document.writeの使い方

Last updated at Posted at 2019-12-13
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>TODAY</title>

  <!--Bootstrap CDN ここから-->
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
    integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

  <!-- Optional theme -->
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
    integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
  <!--Bootstrap CDN ここまで-->
  <link rel="stylesheet" href="styles.css">
</head>

<body>
  <header>
    <h1>TODAY</h1>
  </header>

  <div class="container">
    <script>

      document.write('<p class="date">20xx/1/1</p>');
    </script>

  </div>
</body>
</html>

(''); についての説明

documentは「オブジェクト」 writeは「メソッド」 ('')はパラメータと呼ぶ。
日本語風に言うと、「画面上(オブジェクト)に( )(パラメータ)を書く(メソッド)という意味になる。

const today = new Date(); を使う理由

変数とは設計図を箱の中に入れる作業。

今回の場合、設計図=new Date(); 箱=const today
となる。

【プログラマー未経験者の方へ】
ドットインストールが難しくて萎えている方や、模写コーディングが出来なくて悩んでいる方はUdemyがめっちゃおすすめです。
僕はプログラマー未経験者ですが、以下の記事の講座で模写コーディング、さらには自分でコーディングできるまでになりました。
https://greenberet.net/mosya-coding-udemy/
僕はコーディングできるまでかなり苦しみ、何度も挫折しかけましたが、Udemyに助けられました。
参考にしていただければ幸いです。

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