What is the difference between these jQuery ready functions?

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

what is difference between

$(function(){

}); 

and

$(document).ready(function() { 

});
9条回答
  •  难免孤独
    2020-11-22 15:43

    I suggest you read this. As you can see

    All three of the following syntaxes are equivalent:

    $(document).ready(handler)

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

    $(handler)

    So it's up to you and to what you prefer.

提交回复
热议问题