JSFiddle - React, Tailwind, and code Playground
by gryzzly
HTML
<div id=sample></div>
JavaScript
// Also note, that for $('#sample').myplugin() to work
// you need the element with id "sample" to be existent
// so the function is actually called
(function($){
$.fn.myplugin = function(){
// in your code, the `this` is pointing to
// jQuery object, you can't access `id` attribute
// with dot. You need to either access first element
// in jQuery object (`this[ 0 ]`) or use this.attr('id')
// alert( this[0].id );
alert( this[0].id );
};
})(jQuery);
$("#sample").myplugin();