jquery: Choosing a document.ready method

廉价感情. 提交于 2019-12-01 21:15:40
WTK

Feel free to use either one of them. Just as you think, the latter version is a shorthand for $(document).ready().

The first option was available since the beginning of jQuery releases as oppose to the second option.

Personally I prefer the second version for it is shorter.

All three of the following syntaxes are equivalent:

$(document).ready(handler);

$().ready(handler); //(this is not recommended)

$(handler);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!