How to create this simple looping function?
<p>I have a function that loops on itself. I'm still wrapping my head around how this works and I hope you can help.</p>

<p>Basically I have the following function</p>

<pre><code>function parachute_drop(animation_duration) {
$('#parachute_wrap_2')
        .animate({top: "750px"},animation_duration)
        .animate(
           {top:"-150px"},
           {duration: 0, complete: parachute_drop("'+animation_duration+'")}
        );
}

parachute_drop(90000);
</code></pre>

<p>In my head, this should loop itself and where 'animation_duration' occurs inside the function it should end up with whatever number I put in the call to the function.</p>

<p>The idea is that above over 90 seconds, a parachute falls down 750px. Then in the space of 0 ms, it goes back to the top and off the screen at -150px.</p>

<p>If I were to do:</p>

<pre><code>parachute_drop(1000);
</code></pre>

<p>Then this loop would happen every 1 second.</p>

<p>What don't I understand about functions here - am I unable to put a 'complete' function in with some variables like this? I know that if I took out the 'animation_duration' part out of the function entirely and just put in a fixed duration into it that it works fine. </p>

<p>For example the following works:</p>

<pre><code>function parachute_drop() {
$('#parachute_wrap_2')
        .animate({top: "750px"},9000)
        .animate(
           {top:"-150px"},
           {duration: 0, complete: parachute_drop}
        );
}

parachute_drop();
</code></pre>

<p>... but then my function doesn't have the custom variable options. Thanks for any pointers.</p>
