Created
March 8, 2016 07:13
-
-
Save 14021939/7984b369e2d7ea95f6ef to your computer and use it in GitHub Desktop.
jQueryプラグイン テンプレート ref: http://qiita.com/14021939/items/8ef5e539368462dba991
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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