I know that you can add new jQuery functions by $.fn.someFunction = function()
However, I want to add functions to specific elements only. I tried this
The most obvious solution is to assign a function as the object's property:
obj.prop("myFunc", function() {
return (function(arg) {
alert("It works! " + arg);
});
});
Then call it on the object this way:
obj.prop("myFunc")("Cool!");
Note: your function is the return value of the outer one, see: http://api.jquery.com/prop/#prop-propertyName-function