jQuery 分 2 個系列版本 1.x 與 2.x,主要的區別在於 2.x 不再兼容 IE6、7、8瀏覽器,這樣做的目的是為了兼容移動端開發。由於減少了一些代碼,使得該版本比 jQuery 1.x 更小、更快。
如果開發者比較在意老版本 IE 用戶,只能使用 jQuery 1.9 及之前的版本了。
jQuery是一個JavaScript腳本庫,不需要特別的安裝,只需要我們在頁面 <head> 標簽內中,通過 script 標簽引入 jQuery 庫即可。
1 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
2 <script>
3 // 第一種寫法
4 $(function(){ 5 $("div").html(""); 6 // add your code here
7 }) 8
9 // 第二種寫法
10 $(document).ready(function(){ 11 $("div").html(""); 12 $("a").click(function(){ 13 // add your code here
14 }) 15 }) 16
17 // 第三種寫法
18 window.onload = function(){ 19 // add your code here
20 } 21 </script>