jQuery學習筆記(9)--jquery中的事件--$(document).ready()

來源:互聯網
上載者:User

標籤:

1.$(document).ready()方法是事件模組中最重要的一個函數,可以極大地提高web應用程式的相應速度。

2.執行時機:DOM就緒後就會執行,而javascript中window.onload方法是在網頁中的所有元素(包括元素的所有關聯檔案)完全載入到瀏覽器後才執行。

3.可多次使用。

4.有簡寫的形式:$(function){}

window.onload與$(document).ready()的比較:

 

 1  <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> 2     <script type="text/javascript"> 3  4  5         $(document).ready(function () { 6                        one();                      7  8         }); 9 10         //簡寫形式111         $().ready(function () {12             two();13 14         });15 16         //簡寫形式217         $(function () {18             three();19         });20 21         function one() {22             alert("1");23 24         }25 26         function two() {27             alert("2");28 29         }30 31         function three() {32             alert("3");33 34         }35     </script>
View Code

 

jQuery學習筆記(9)--jquery中的事件--$(document).ready()

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.