JSFiddle - React, Tailwind, and code Playground

by salitrapraveen

JavaScript

(function($) {
    var num, methods = {
        init: function(options) {
            // THIS 
        },
        set: function(n) {
            num = n;
        },
        get: function() {
            return num;
        }
    };

    $.fn.prvn = function(method) {

        // Method calling logic
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.tooltip' );
    }  

    };

})(jQuery);

$(function() {
    $('body').prvn('set', 12);
    alert($('body').prvn('get'));
});