jQury: when DOM is ready

當 HTML 文件的 DOM 準備好之後,有趣的事情就要發生,怎麼做呢?把要做的東西放到下面 "do stuff when DOM is ready" 的地方:

$(document).ready(function() {
   // do stuff when DOM is ready
 });

不過這樣寫也可以,也就是所謂 $(fn) 的方式,"fn" 指的就是一個 javascript function

$(function() {
   // code to execute when the DOM is ready
 });

我當然是選後者來用。

0 comments on jQury: when DOM is ready

    Post new comment

    The content of this field is kept private and will not be shown publicly.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><img><blockquote>
    • Lines and paragraphs break automatically.

    More information about formatting options

    CAPTCHA
    This question is for testing whether you are a human visitor and to prevent automated spam submissions.