Are $(function(){}); and $(“document”).ready(function(){}); the same?

后端 未结 2 817
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-11 19:17

I\'ve been enjoying Lynda.com\'s Jquery Essential Training, and I\'ve noticed that in the beginning the instructor uses:

    Fig. 1

    $(\"document\").read         


        
2条回答
  •  青春惊慌失措
    2020-12-11 19:52

    Yes, they are exactly the same, just aliases.

    From the jQuery site:

    All three of the following syntaxes are equivalent:

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

提交回复
热议问题