一、jQuery概述html
jQuery是一個JavaScript庫,它集成了JavaScript、DOM、CSS和Ajax,簡化了JavaScript編程,提倡write less, do more。jquery
二、jQuery與JavaScript的區別編程
三、jQuery頁面加載完畢事件less
如下代碼執行會先彈出jQuery頁面加載完畢事件「頁面加載完畢事件」和「頁面加載完畢匿名函數」,而後執行js方法,彈出「init()方法」函數
當點擊按鈕時,只會彈出「點擊按鈕彈出框2」spa
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>jQuery頁面加載完畢事件</title> 6 <script src="js/jquery-1.11.0.js"></script> 7 <script src="demo.js"></script> 8 <script> 9 window.onload = function() { 10 document.getElementById("a").onclick = function() {alert("點擊按鈕彈出框1")}; 11 document.getElementById("a").onclick = function() {alert("點擊按鈕彈出框2")}; 12 } 13 </script> 14 </head> 15 <body onload="init()"> 16 <button id="a">click</button> 17 </body> 18 </html>
1 function init() { 2 alert("init()方法") 3 } 4 5 $(document).ready( 6 function() { 7 alert("頁面加載完畢事件"); 8 } 9 ) 10 11 $(function() { 12 alert("頁面加載完畢匿名函數"); 13 })