Code inside DOMContentLoaded event not working

前端 未结 7 1606
一向
一向 2020-12-04 20:10

I have used




  


  
7条回答
  •  孤街浪徒
    2020-12-04 20:23

    My clean aproach...

    if (document.readyState !== 'loading') init()
    else document.addEventListener('DOMContentLoaded', init);
    
    function init() {
        console.log("Do it !");
        ...
    }
    

提交回复
热议问题