JSFiddle - React, Tailwind, and code Playground

HTML

<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>

JavaScript

(function($) {
    $.fn.extend({
        myTestPlugin: function() {
            
            if (this.length > 1) {
                this.each(function() { $(this).myTestPlugin(); });
            }
            
            this.done = function() {
                $(this).html('Done!');
            };
            
            var alsoDone = function() {
                $(this).html('Also done!');
            };
            
            this.html('Replace me!');
            this.on('alsoDone', alsoDone);
        }
    });
})(jQuery);
var $boxes = $('.box');
$boxes.myTestPlugin();
$boxes.eq(0).trigger('alsoDone');
$boxes.eq(0).done();