Some jQuery methods expect a function as a parameter, but to work, they must receive an anonymous function as a parameter, not a function directly, as in the following example:
$("a").on("click", function () { retornaNada(); });
but not
$("a").on("click", retornaNada());
Consider retornaNada() as a function without any code. Why can't we pass the function directly?
source share