js Code
window.onload=function(){
console.log(2)
}
console.log(1)
html code has nothing but:
- introduce the above js into the head tag
- body tag finally introduces
- introduce outside the html tag
then compare the consoles of the three cases.
- the first case: first 1, then 2. It is not difficult to understand that because the DOM has not been loaded in head, so wait for the document to be loaded first and output 2 .
- the second case: my understanding is that in the final introduction, the js dom has been loaded and it should be 2 after 1. Unfortunately, my test result is still 1 after 2 .
- third case: write script outside the entire html and tag, unfortunately 1 followed by 2
after testing the read function of jquey, the result is the same (there is no picture for typing on mobile phone)