それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

jquery の document readyは今でも正しいのか?

jquery の document.ready は初期の頃から使っているが、最近は見かけなくなりつつ。deprecatedになってobsoleted なのかなと思って気になっていた。たまたまbind関連を探していて見つけた。いまでもどんどん使って問題ないらしい。安心した。

All three of the following syntaxes are equivalent:

$(document).ready(handler)
$().ready(handler) (this is not recommended)
$(handler)

There is also $(document).bind("ready", handler), deprecated as of jQuery 1.8. This behaves similarly to the ready method but if the ready event has already fired and you try to .bind("ready") the bound handler will not be executed. Ready handlers bound this way are executed after any bound by the other three methods above.


The .ready() method can only be called on a jQuery object matching the current document, so the selector can be omitted.
The .ready() method is typically used with an anonymous function:

http://api.jquery.com/ready/

というわけで、どれでも同じです。