Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Thanked 0 Times in 0 Posts

    Javascript and Div tag linking

    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 ?

  2. #2
    New Coder
    Join Date
    Jan 2011
    Thanked 5 Times in 5 Posts
    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.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts