You'll learn to love anonymous functions. And eventually, you'll even learn
to love closures:
(function($) {
// do something
})(jQuery);
I guess cleanliness is relative. It looks pretty clean to me. The goal of
anonymous functions is to be able to pass around chunks of code to be
executed
You have to use functions in that code, because you are using two callbacks,
and that's how you do callbacks in JavaScript, with
functions that get called later.
The first callback is the outer function that gets called when the document is
ready.
The second callback is the inner function
2 matches
Mail list logo