What jQuery event is called right after $(document).ready()?

前端 未结 8 897
囚心锁ツ
囚心锁ツ 2021-01-13 08:47

I have lots of HTML generated on $(document).ready(). I have a simple window system. But not only it is generated on $(document).ready() - also som

8条回答
  •  一生所求
    2021-01-13 09:14

    I usually don't advocate using setTimeout, but you can build on top of @jfriend00's answer to create a more abstract approach:

    $(document).ready(function() {
        setTimeout(function() {
            $(document).trigger('afterready');
        }, 1);
    });
    
    $(document).bind('afterready', function() {
        // call your code here that you want to run after all $(document).ready() calls have run
    });
    

提交回复
热议问题