JSFiddle - React, Tailwind, and code Playground
by Filipp Dernovoy
HTML
<div class="js-slider">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
JavaScript
(function($) {
var methods = {
init: function(options) {
return false;
}
};
$.fn.sliderController = function(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 + ' is undefined for jQuery.sliderController');
}
};
})(jQuery);
$('.js-slider').sliderController();