What is the difference between these jQuery ready functions?

后端 未结 9 1505
名媛妹妹
名媛妹妹 2020-11-22 15:31

what is difference between

$(function(){

}); 

and

$(document).ready(function() { 

});
9条回答
  •  孤独总比滥情好
    2020-11-22 15:58

    They're effectively the same. No difference.


    This is the native way.

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

    And this is a shorthand for the previous.

    $(function() {
        // code
    });
    

    jQuery source code

提交回复
热议问题