Executing JavaScript in the <head>, getElementById returns null

前端 未结 3 1223
旧巷少年郎
旧巷少年郎 2021-01-05 00:49

I have following code





        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-05 01:17

    This JS code will run before the DOM is ready so the node will not be found. To perform execution only once the DOM is ready, you could use the window.onload event handler.

提交回复
热议问题