Procedure when the sequential execution, script to write in the back of the web framework… If you want to write in front of you, you need to use deferred execution and you need to write the JS block in

```js window.onload = function(){ }; ` ` `Copy the code

Among them

<! DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta  name="viewport" content="width=device-width, "> <title>Document</title> <script Var box1 = document.getelementById ('box1'); function(){var box1 = document.getelementById ('box1'); Var box2 = document.getelementById ('box2'); console.log(box1); console.log(box2); }; < / script > < / head > < body > < div id = "box1" > I am a box 1 < / div > < div id = "box2" > I am a box 2 < / div > < / body > < / HTML >Copy the code