JSFiddle - React, Tailwind, and code Playground
by javad ebrahimi
HTML
<div class="foo"></div>
<div class="foo"></div>
<div class="bar"></div>
JavaScript
(function($) {
$.fn.extend({
myplugin: function(options) {
if (options && typeof(options) == 'object') {
options = $.extend({}, $.fn.myPlugin.defaults, options);
}
this.each(function() {
new $(this).myPlugin(options);
});
return;
}
});
$.fn.myPlugin = function(methodOrOptions) {
var elem = this;
var method = {
init: function() {
$(D).on("mouseenter", function() {
console.log(D.id);
});
},
one: function() {
}
};
if (jj[methodOrOptions]) {
return jj[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
return jj.init.apply(this, arguments);
} else {
$.error('متد ' + methodOrOptions + ' تعریف نشده است.');
}
};
$.fn.myPlugin.defaults = {
text: "welcome";
};
})(jQuery);