5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

HTMLでJavaScriptを読み込む方法

Posted at

はじめに

HTMLでJavaScriptを読み込む方法について学んだので,アウトプットしていきます.

方法1:JavaScriptをHTML内に記述する

scriptタグ内にJavaScriptのコードを書いていく.HTMLの読み込みが途中で止まらないように,bodyタグの最後に書くことが奨励されている.

<body>
    <header></header>
    <main></main>
    <footer></footer>
    <script>
        //ここにJavaScriptのコードを記述
    </script>
</body>

方法2:JavaScriptを外部ファイルとして読み込む

scriptタグのsrc属性にJavaScriptファイルを指定する.

<body>
    <header></header>
    <main></main>
    <footer></footer>
    <script src="hogehoge.js"></script>
</body>

参考サイト

5
5
1

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
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?