jQuery的三種寫法
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>
其中,第一種是簡寫方式,也是我比較喜歡用的一種