Skip to content

Instantly share code, notes, and snippets.

@14021939
Created March 8, 2016 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 14021939/7984b369e2d7ea95f6ef to your computer and use it in GitHub Desktop.
Save 14021939/7984b369e2d7ea95f6ef to your computer and use it in GitHub Desktop.
jQueryプラグイン テンプレート ref: http://qiita.com/14021939/items/8ef5e539368462dba991
(function($){
var methods = {
init : function( options ) {
var elements = this
var settings = $.extend(true, $.fn.test.defaults, options);
console.log(settings)
elements.each(function() {
// 処理をここに記述する
});
return this;
}
};
$.fn.test = function( method ) {
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.test' );
}
};
$.fn.test.defaults = {
default: true,
};
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment