cycling jQuery_Succinctly | Page 91

Obviously, there could be a lot of variation of this pattern depending on the options, complexity, and functionality of the plugin. The point here is that plugins can be called via existing DOM elements, as well as those created on the fly. Providing callbacks and passing context When authoring jQuery plugins, it is a good idea to provide callback functions as an option, and to pass these functions the context of this when the callback is invoked. This provides a vehicle for additional treatment to elements in a wrapper set. In the code below, we are passing a custom option to the outAndInFade() plugin method that is a function and should be called once the animation is complete. The callback function is being passed the value of this when it's being invoked. This allows us to then use the this value inside the function we defined. When the callback function is invoked, the keyword this will refer to one of the DOM elements contained within the wrapper set. Sample: sample91.html
Out And In Fade
Out And In Fade