JavaScript筆記3_變數

qqq777_發表於2020-11-24
<!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>
     var age;//宣告一個age的變數
     age=10;//賦值
     alert(age);
     var myname='blue';
     console.log(myname);
    </script>
</head>
<body>
</body>
</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>
       var id;
       id=prompt('input your id');
       alert(id);

    </script>
</head>
<body>
</body>
</html>

相關文章