Run JavaScript function when the DOM is “ready”?

前端 未结 7 2154
一生所求
一生所求 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:28

    The easiest solution is using jQuery and its $(document).ready(function() { .... }); function. Instead of .... you put your own code.

    Note that it basically does the same thing @Shadow2531 suggested, but also works in old browsers not supporting that event.

提交回复
热议问题