I have written a function and intend to call it in several circumstances. Here is the function:
var responsive = function(){
$('#menuicon').toggleClass('menuicon-res');
$('.fixed-menu-item').toggleClass('res');
}
In a certain case, calling the function works only when written WITHOUT parenthesis after it:
$('#menuicon').click(responsive);
In another, similar case, calling the function works only when written WITH parenthesis after it:
$('#top').click(function(){
$('html, body').animate({scrollTop: 0},500);
responsive();
});
I think I understand that the first case (w/o parenthesis) returns the function for callback, and the second case (w/ parenthesis) returns the output of the function. Can anyone help explain why the way to call my function changes in these two scenarios?
Thanks;
CPR