jQuery plugin structure

HTML

<div id="debug">Click on a button to run the plugin</div>
<button onclick="$.fn.myplugin()">Run default action</button>
<button onclick="$.fn.myplugin('function1')">Run function 1</button>
<button onclick="$.fn.myplugin({a:1})">Run function 2</button>

JavaScript

$.fn.myplugin = function(options) {
    if(typeof(this[options]) == 'function') {
        return this[options]();
    }
    $("#debug").html(options.a);

    this.function1 = function() {
        $("#debug").html("I've just run function1()");
    }
    
    this.function2 = function() {
        $("#debug").html("I've just run function2()");
    }    
}