jquery anonymous function declaration meanings

后端 未结 2 1632
囚心锁ツ
囚心锁ツ 2021-01-30 06:02

Are the following assumptions accurate?

1) execute immediately

(function(){
})();

2) execute on document ready

$(docume         


        
2条回答
  •  误落风尘
    2021-01-30 06:10

    Here's the #4 you were looking for:

    jQuery(function ($) {
    });
    

    It will run on document.ready, within a namespace, and with jQuery defined as $.

提交回复
热议问题