JSFiddle - React, Tailwind, and code Playground
HTML
<div class="a">A</div>
<div class="b">B</div>
<a href="#">click</a>
JavaScript
(function() {
var settings = {};
var methods = {
init : function(options) {
return this.each(function(n) {
var settings = $.extend(true, {
duration : 1000,
}, options);
settings.duration = Math.round(Math.random()*10000);
$(this).data("settings", settings);
});
},
showw : function() {
return this.each(function(n) {
var settings = $(this).data("settings");
alert(settings.duration);
// do stuff
});
}
};
$.fn.expander = function(method) {
alert(method);
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.expander');
}
};
$(function(){
// $("div").expander();
// $("a").click(function(e){
// $("div").expander("showw");
// return false;
// });
var $divA = $("div.a");
var $divB = $("div.b");
$divB.expander();
$divB.expander();
$("a").click(function(){
$divA.expander("showw");
//$divB.expander("showw");
});
});
})(jQuery);