Run JavaScript function when the DOM is “ready”?

前端 未结 7 2171
一生所求
一生所求 2020-12-03 10:04

I\'m using a JavaScript upload script that says to run the initialize function as soon as the DOM is ready. I currently have it working just fine with either a call to the f

7条回答
  •  误落风尘
    2020-12-03 10:31

    The DOM is usually ready before onLoad runs. onLoad only runs after everything loads - external scripts, images, stylesheets, etc.

    But the DOM, i.e. the HTML structure is ready before that. If you run the code at the bottom of the page (or after the parts of the page the script works with) that will work fine as well.

提交回复
热议问题