プラグインを自作する際のテンプレート
”test”(仮称)を任意の名前に変換して使う
(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)