View Full Version : Javascript and Div tag linking

02-15-2011, 09:01 AM
I have a code as following:

<div id="animation">
<script type="text/javascript">

javascript code goes here..... it is nothing but some text animation


now i want to put the javascript code into external javascript file and i want to run that animation under <div id="animation">
Any suggestions how can i achieve this ?

02-15-2011, 10:09 AM
The javascript should presumably be targeting a div called animation anyway, simply place the function in external js. file like normal.

Link to that script in your header.

Now the choice is how you call it, I'm guessing here you could just do <body onLoad="yourFunction()"> and that would fulfill your needs.

If the function you write/have handles the div target as this obj then you have to call the function in a slightly different way.