Yes, I learned a lot because of you guys! Thank you. It works like a charm: http://www.lightwavers.net/dadda/
cu tom On Jan 17, 9:37 am, Hamish Campbell <[EMAIL PROTECTED]> wrote: > Ah so, you learn something new everyday! > > On Jan 16, 5:34 pm, fuzziman <[EMAIL PROTECTED]> wrote: > > > [EMAIL PROTECTED] wrote: > > > > Remember that variables declared within functions only exist for that > > > function. > > > Not really... > > > As others mentioned, the crux of the problem is because setInterval is > > calling "force()" which refers to the global scope. > > > Try passing in the reference to the function rather than a string, because > > you can still access this within the closure. Avoid putting things in the > > global scope, unless namespaced. > > > Example: > > > <script type="text/javascript"> > > $(document).ready(function(){ > > function force() { > > console.log('whooosh ' + new Date()); > > }; > > $('#joda').click(function () { > > setInterval(force,1000); > > }); > > }); > > </script> > > > -- > > View this message in > > context:http://www.nabble.com/simple-newbie-js-function-problem...-tp14848309... > > Sent from the jQuery General Discussion mailing list archive at Nabble.com.