【筆記】jQuery介紹與使用
阿新 • • 發佈:2018-11-30
簡單介紹jQuery:
jQuery 是一個 JavaScript 庫。
jQuery 極大地簡化了 JavaScript 程式設計。
jQuery 很容易學習。
安裝jQuery:
進入jQuery官網,下載jQuery庫,然後在html頁面中引用。例如:
<head> <script src="jquery-3.3.1.js"></script> </head>
另外,jquery.js檔案無壓縮,用於測試和學習;jquery.min.js檔案已壓縮,用於實際的網站。
使用CDN引用:
如果不想下載jQuery檔案,可以使用這些CDN,
谷歌CDN:
<head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </head>
微軟CDN:
<head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script> </head>
百度CDN:
<head> <script src="https://apps.bdimg.com/libs/jquery/3.3.1/jquery.min.js"></script> </head>
官方:
<head> <script src="https://code.jquery.com/jquery-3.3.1.js"></script> </head>
等等......
使用者訪問其他網站時可能已經載入過jQuery,在訪問您的頁面是會從快取中載入jQuery,提高載入速度。