I have a jQuery function:
$(".foo").click(function(event) {
console.log(event.type);
});
I'd like to extract the function:
function logEventType(event) {
console.log(event.type);
}
When I try to call it with the parameter:
$(".foo").click(logEventType(event));
it runs automatically on page load and doesn't operate on click function. However, if I call it without the parameter:
$(".foo").click(logEventType);
it runs exactly like I'd hope. I guess I have it working fine, but I'm just wondering what's going on and why.