开发者

Order of loading DOM elements

开发者 https://www.devze.com 2023-02-21 06:34 出处:网络
Very simple question. If I have this: <link id=\"lowtech\" rel=\"stylesheet\" type=\"text/css\" href=\"css/lowtech.css\" />

Very simple question.

If I have this:

<link id="lowtech" rel="stylesheet" type="text/css" href="css/lowtech.css" />
&l开发者_如何学Ct;script type="text/javascript" src="js/engine.js"></script>

Inside the engine.js I have

document.getElementById("lowtech");

Will that always work? Does the browser load DOM elements in a linear fashion every time? Is there some specification about this process?


Will that always work?

Yes

Does the browser load DOM elements in a linear fashion every time?

The exception is when JS adds DOM elements. Since events can fire at different times, the instructions to add those elements can be run at different times.


if your document.getElement is after window.load event

0

精彩评论

暂无评论...
验证码 换一张
取 消