[Solved] Moving a changes the result: why?

[ad_1]

That’s happens because the script run before document is ready. ( sync ).
If you want to keep your script at the beginning of the body, or in head, use de window.onload function.

window.onload = function()
{ 
 // your code goes here
}

My suggestion will be to place the script at the end of the body, also
the bootstrap and jquery libs, because those scripts will be fired
after the DOM is ready.

[ad_2]

solved Moving a