JSFiddle - React, Tailwind, and code Playground
HTML
<div class="test"></div>
<div class="test"></div>
<div class="test_"></div>
JavaScript
$.fn.foo = function (prop) {
var options = $.extend({
"elt" : "", // Declaration of my options
"callback" : function(){}
}, prop);
var optionsTab = options.elt.split('#');
var current = optionsTab.slice(0,1);
var remaining = optionsTab.slice(1);
this.each(function() {
var el = $(this);
// Code handling the first element in the option
el.html(el.html()+current[0]);
});
if (remaining.length > 0) {
this.foo({ "elt": remaining.join("#") }); // Trial of recursion of foo
}
return this;
};
$(".test").foo({elt: "a#b#c"});