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?

【備忘録】JavaScript

Posted at

Java script

項目 let var const
再宣言 × ×
再代入 ×
スコープ ブロックスコープ 関数スコープ ブロックスコープ
使う場面 よく使う 昔は使ってた 定数の場合使う

01. 基本構造

HTMLの場合

<head>
    <script>
        function alert() {
            alert("alert");
        };
    </script>
</script>
<body>
<button onclick="alert()">alert</button>
</body>

jsファイルの場合

function alert() {
    alert("alert");
};

02. 基本構文

alert

function alert() {
    alert("alert");
};

confirm

  • 確認ダイアログ
  • yesとnoの2択
  • preventDefault() デフォルトの挙動を止める
function alert() {
    var result = conirm("OK?");
    if(result==false) { event.preventDefault() }
    else {return true};
};

HTML書き換え

document.write("<div>hoge</div>");

for

for(let i=0; i < 10; i++;){
    alert(i);
}
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?