[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...-tp14848309s27240p14865200.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to