jquery: Choosing a document.ready method

后端 未结 2 1819
太阳男子
太阳男子 2021-01-21 01:48

I\'m new to jquery. I\'ve just read that these 2 are equivalent:

$(document).ready(function() {});

$(function() {});

Which one

2条回答
  •  不要未来只要你来
    2021-01-21 02:14

    All three of the following syntaxes are equivalent:

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

提交回复
热议问题