LoginSignup
0
1

More than 5 years have passed since last update.

javascriptの基本

Last updated at Posted at 2019-01-30

:point_up_tone3: javascriptとは・・・・

Webページを操作するためのプログラミング言語で、WEBサイト上のHTML要素を取得したり、要素を操作したりすることができます。
HTMLやCSSをリアルタイムに変更も可能です。


*導入
index.htmlに記入する場合

<body>
 <script>
  window.alert("おはよう");
 </script>
</body>


こんなふうに<script></script>で囲ってあげましょう!

メソッドの紹介

メソッド 説明
◎window.alert(" ") アラートを表示する
◎console.log(" ") ブラウザのコンソールとよばれるところに表示する

*導入2
javascriptを外部ファイルから読み込む場合
①拡張子.jsファイルを作成
(test.js)
②HTMLの

<head> 
</head>

に外部ファイルを読み込むコードを書く

<script src="読み込みたいJavaScriptファイルのパス"></script>

今回は、htmlファイルと同じ階層におくので,

<script src="test.js"></script>

これで完成。
あとは、jsファイルにコードを書いていきます。

0
1
2

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
1