# 創建插件
可以通過添加方法作為 [`$.fn`](#$.fn) 的屬性來寫插件:
```
;(function($){
$.extend($.fn, {
foo: function(){
// `this` refers to the current Zepto collection.
// When possible, return the Zepto collection to allow chaining.
return this.html('bar')
}
})
})(Zepto)
```
為了更好開始開發插件,先看下[source of Zepto's core module](https://github.com/madrobby/zepto/blob/master/src/zepto.js),并確認讀過[coding style guidelines](https://github.com/madrobby/zepto#code-style-guidelines)