JSFiddle - React, Tailwind, and code Playground

by jabbad

HTML

<input type="text" id="txt1" />
<input type="text" id="txt2" />

JavaScript

(function ($) {
    $.fn.myPlugin = function () {   
    var nameControl = this.attr('id');
    $(this).css('border','1px solid red')
    
    $.fn.myPlugin.id = function () {
    	alert(nameControl);           
    };
    
     return this;
    };
}(jQuery));


$("#txt1").myPlugin();
$("#txt2").myPlugin();


$("#txt1").myPlugin.id();
$("#txt2").myPlugin.id();