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

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -