The callback function is used to pass one function as a parameter to another function as the return result in another function.
Here is a simple example of a callback function: Tom went to the store to buy something, just out of stock, the shopkeeper asked him to take the information recorded in the book, a few days and there is goods, the shopkeeper on the book to find Tom's phone, the shopkeeper to find the phone is a callback function.
function Outputphone (name) { + "Phone: 10000");} // functions that use callback functions function SearchInfo (name, callback) { callback (name);} // searchinfo ("Tom", Outputphone);
The advantage is that you can use the existing parameters, call different functions, such as Tom above, if you do not get the number, you can also change a callback function, get home address ah .... Age, Ah, something like that.
Examples of common callback functions in jquery:
$ (' #id '). On ("click", Callback);
The callback function is always around ..... It's just that we're accustomed to ....
JavaScript callback function