Create a callback function within a custom jQuery function
- by Thomas
I'm not sure how to approach this as I am fairly new to jQuery. I'm wanting to create a callback function within a custom function. Here's my example:
function doSomething() {
var output = 'output here';
// Do something here
// This is where I want to create the callback function and pass output as a parameter
}
I want the callback function to be accessible by any number of scripts (e.g. more than one script can access this callback).
This function (doSomething) is not part of a plugin but rather part of another callback function itself. I've also created a var within the function and want to pass that through the callback function as well.
How can I do this?