JSFiddle - React, Tailwind, and code Playground
HTML
<p class='a'></p>
<p class='a'></p>
<p class='a'></p>
<p class='a'></p>
<p class='b'></p>
<p class='b'></p>
<p class='b'></p>
JavaScript
$.widget("me.mywidget", {
options: {
static1: "1", //defaults
static2: "2",
static3: "3"
},
// Constructor. This is called when mywidget is initialized
_create: function () {
this.element.text(this.options.static1);
}
});
$(".a").mywidget({ //call it on all .a <p>
static1: "I am part of the .a selection"
});
$(".b").mywidget({ //call it on all .b <p>
static1: "I am part of the .b selection"
});