I have written a jQuery plugin like this:
jQuery(function($) {
$.fn.myPlugin = function() {
return this.each(function () {
this.publicFunction = function() {
alert('test');
};
return this;
});
};
});
My JavaScript on my HTML page looks like this:
var myPluginDiv = $("#divTest").myPlugin();
myPluginDiv.publicFunction();
And I get the error "myPluginDiv.addItem is not a function." It's clearly a public function. Why is it not working?