How do you handle click events inside a plugin? A simplified description is that I want to have a plugin that will detect a click and then update another element.
Example Usage:
$("#some_id").myPlugin("another_id");
Example Plugin:
(function($){
$.fn.myPlugin=function(update_id){
.click({$(update_id).html("content_upated");});
}
})(jQuery);
I don’t understand how to code the .click event inside the plugin. Any examples would be helpful. Thanks.
You should do two things:
thisto reference the elements to which your plugin is being appliedTry the following
You should read the page on jQuery plugin authoring for more information on how to correctly develop jQuery plugins. You’re missing other important details like accepting an arguments object.