jquery - Why would JavaScript work correctly in HTML body but not as a JavaScript file in the HTML header -
This does not work (placed inside the HTML header tag):
& Lt; Script src = "file / js / animator / index.js" charset = "utf-8" & gt; & Lt; / Script & gt;
but it works fine (placed inside the HTML body tag):
& lt; Script & gt; $ (Function () {$ ("active"). Animate ({height: "10%"}, 5000);}); & Lt; / Script & gt;
Why does it work properly and why not do it for the first time?
You need to run your function such as
& lt ; Body onload = "animate ()" & gt;
Otherwise you will need something on the document load script in your JP file.
Comments
Post a Comment