jQuery的三種寫法


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>

其中,第一種是簡寫方式,也是我比較喜歡用的一種


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM