18
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

jQueryプラグイン定義チートシート

Last updated at Posted at 2014-02-02

チートシートなので詳細な説明はなしです。

jQueryプラグイン定義の書き方。

メソッドとかもった高機能なやつはExtending jQuery Boilerplateを見てください。

(function ($) {
    $.fn.pluginName = function(options){
        // default option values
        var settings = $.extend({
            optionName: "defaultOptionValue"
        }, options);
        
        return this.each(function(){
            var obj = $(this);

            // settingsをもとにobjに対して処理
        });
    };    
    
})(jQuery);

// usage
$("#id").pluginName({optionName: "optionValue"});
18
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?