jQuery: Enforce order of execution of document.ready() calls

后端 未结 5 881
小蘑菇
小蘑菇 2020-12-10 23:45

I\'m working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called befor

5条回答
  •  离开以前
    2020-12-11 00:23

    As @jfriend00 mention that ready callbacks are called in the order they were registered.

    So even if this code block called on the beginning, you can set another callback in it so it'll be executed on endmost.

    jQuery(document).ready(function(){
        jQuery(document).ready(function(){
            // This block will be executed after all ready calls.
        });
    });
    

提交回复
热议问题