How does the location of a script tag in a page affect a JavaScript function that is defined in it?

后端 未结 9 1260
死守一世寂寞
死守一世寂寞 2020-11-29 04:27

I read that you should define your JavaScript functions in the tag, but how does the location of the

9条回答
  •  借酒劲吻你
    2020-11-29 05:12

    If your script refers to an ID on the page and the page has not been rendered (i.e. script is before HTML, or your script is executed with onload, rather then the DOM is ready) you can also get an error.

提交回复
热议问题