Delaying a jquery script until everything else has loaded

后端 未结 6 750
旧巷少年郎
旧巷少年郎 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:36

    Multiple $(document).ready() will fire in order top down on the page. The last $(document).ready() will fire last on the page. Inside the last $(document).ready(), you can trigger a new custom event to fire after all the others..

    Wrap your code in an event handler for the new custom event.

    
    
    
    
    ... other code, scripts, etc....
    
    
    
    
    

提交回复
热议问题