memo:jQueryプラグインの作り方

http://www.goodpic.com/mt/archives2/2007/11/jquery.html
から。
メソッドチェーンをしないjQueryは逆に混乱を招くので
return thisは必須だとおもふ。

//jQueryの関数を定義
(function(){
  jQuery.fn.MyPluginName = function(config){
    //引数の処理部
    config = jQuery.extend({
                 value1:"引数のデフォルト",
             },config);

    //処理本体     
    //プラグインの中のthisは$("div")などとセレクトした要素
    this.append("Hello! jQueryPlugin!<br/>value1" + config.value1);//そのままjQueryの関数は使える
    return this;
  };
}(jQuery));//実のところ;は必須ではないけど\n消す

//利用する
$(function(){
    $(".target").MyPluginName({value1:"tttt"}).append("そして");
});