Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: さまざまな形式の$(document).ready これらのjQuery対応関数の違いは何ですか?
次の2つの機能の違いは何ですか?:
$(function() { });
と
$(document).ready(function(){});
.readyは、DOMの準備ができたときに使用するハンドラー関数です。.ready()メソッドは、通常、属性と互換性がありません。$(function() {});普通に使います。
$(function() {});
$(document).ready(function(){});通常、無名関数に使用されます
次の3つの構文はすべて同等です。
$(document).ready(handler) $().ready(handler) (this is not recommended) $(handler)
http://api.jquery.com/ready/