Some jQuery methods expect a function as a parameter, but to work they should receive an anonymous function as a parameter rather than a function directly, as in the following example:
$("a").on("click", function () { retornaNada(); });
rather than
$("a").on("click", retornaNada());
Consider retornaNada()
as a function without any body of code. Why can not we pass the function directly?
It's working but you need to pass only the function reference (name) like this :
function test (e) {
console.log('test ok');
}
$('body').on('click', test);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With