JQuery best practice, using $(document).ready inside an IIFE?

前端 未结 4 1431
我在风中等你
我在风中等你 2020-12-07 16:40

I am looking at a piece of code:

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


        
4条回答
  •  旧时难觅i
    2020-12-07 17:41

    IIFE does the functions when the Execution Context ( scope of the current code that is being evaluated ) is ready. Check the article about Code Organization Concepts in jQuery which describes the two most common patterns, The Object Literal and The Module Pattern, and how to use them.

提交回复
热议问题