JSFiddle - React, Tailwind, and code Playground

by jms_a88

HTML

<div id="example">sdfgsdfg</div>

JavaScript

(function($){
    $.mbAccordion = function(el, options){
        // To avoid scope issues, use 'base' instead of 'this'
        // to reference this class from internal events and functions.
        var base = this;
        
        // Access to jQuery and DOM versions of element
        base.$el = $(el);
        base.el = el;
        
        // Add a reverse reference to the DOM object
        base.$el.data("mbAccordion", base);
        
        base.init = function(){
            base.options = $.extend({},$.mbAccordion.defaultOptions, options);
            
            // Put your initialization code here
        };
        
        // Sample Function, Uncomment to use
        // base.functionName = function(paramaters){
        // 
        // };
        
        // Run initializer
        base.init();
    };
    
    $.mbAccordion.defaultOptions = {
    };
    
    $.fn.mbAccordion = function(options){
        return this.each(function(){
            (new $.mbAccordion(this, options));
        });
    };
    
    // This function breaks the chain, but returns
    // the mbAccordion if it has been attached to the object.
    $.fn.getmbAccordion = function(){
        this.data("mbAccordion");
    };
    
})(jQuery);

$("#example").mbAccordion();