Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
;(function($) { $.fn.myPlugin = function(options) { const defaults = { /* ... */ }; const settings = $.extend({}, defaults, options); return this.each(function() { if ($(this).data("myPlugin")) return; // no double init const instance = { settings, el: this }; $(this).data("myPlugin", instance); // Setup events with namespace $(this).on("click.myPlugin", handler); }); }; }(jQuery));
Result
Open