Delaying a jquery script until everything else has loaded

后端 未结 6 758
旧巷少年郎
旧巷少年郎 2020-11-29 18:49

I have a jquery script which I need to run only once everything else on the page, including some other javascripts (over which I have no control) have finished doing their t

6条回答
  •  清酒与你
    2020-11-29 19:33

    You can have $(document).ready() multiple times in a page. The code gets run in the sequence in which it appears.

    You can use the $(window).load() event for your code since this happens after the page is fully loaded and all the code in the various $(document).ready() handlers have finished running.

    $(window).load(function(){
      //your code here
    });
    

提交回复
热议问题