javascript-1初探

筆記種類
javascript

javascript

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>test</h1>
    <script src="./test.js"></script>
    <!-- javascript通常放在這個位置,因為html跟css先載入,
        之後再跑js,時間進度上這樣使用者比較會有想留在這裡的意願 -->
</body>
</html>

 

javascripet常用函式

console.log("hello world") 
// 將訊息輸出到console中
window.alert("歡迎來到網站")
// 將訊息輸出至選擇"ok"的上方提示
window.prompt("")
// 給予使用者輸入的選項(一進入網頁就會出現)


let user = window.prompt()
window.alert("welcome " + user)