瀏覽器搜尋 jQuery官網
點選DownLoad jQuery
Download the compressed, production jQuery 3.6.4
compressed
代表已經壓縮過的版本,程式碼會連在一起,雖不好閱讀但檔案較小,載入時間較短Download the uncompressed, development jQuery 3.6.4
uncompressed
代表為沒有壓縮的版本,程式碼會有分段,好閱讀但檔案較大,載入時間較長存放在本地端的JavaScript資料夾
於HTML檔案的</body>標籤前面,引入jQuery檔案
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="JS/jquery-3.6.4.min.js"></script> //引入的 jQuery 檔案在這裡,注意路徑
</body>
</html>
於css資料夾內創建一個all.js,用來撰寫jQuery語法,然後將它引入HTML檔案內
$(document).ready(function () {
// jQuery 語法
});
總結 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<title>Document</title>
</head>
<body>
<h1>1234</h1>
<script src="js/jquery-3.6.4.min.js"></script> **//載入jQuery (本地端) 檔案,下載好的**
<script src="js/all.js"></script> **//載入需要撰寫的jQuery檔案**
</body>
</html>