I am ciruious to know what are the reasons that could cause a function “not being” one.
For example, I have the following:
$.fn.myfunction = function(options){
alert("test");
};
$("#hello").myfunction();
alert($.fn.myfunction instanceof Function);
Why would FireBug, log that it is not a function?
Thanks in advance.
Edit:
I would like a list of all the possibilities that could be the reason for the error.
This isn’t an error I got, but I just want to widen my perspective and be aware of more possibilities.
Setting
$.fn.myfunctionmakes themyfunctionfunction available to the object returned by$(selector), not to$itself.Thus,
$("#hello").myfunctionis a function but$.myfunctionis not. If you really want$.myfunctionto be a function for some reason (e.g., it’s a utility function that doesn’t need a jQuery object list to operate), just set it explicitly, without using$.fn: