Skip to content

Instantly share code, notes, and snippets.

@monsat
Created July 16, 2011 05:34
Show Gist options
  • Save monsat/1086044 to your computer and use it in GitHub Desktop.
Save monsat/1086044 to your computer and use it in GitHub Desktop.
initial of jquery plugin
(function($) {
$.fn.pluginname = function(options) {
// build main options before element iteration
var opts = $.extend({}, $.fn.pluginname.defaults, options);
opts.debug && debug(this);
// iterate and reformat each matched element
return this.each(function() {
$this = $(this);
});
};
// private function for debugging
function debug($obj) {
if (window.console && window.console.log) {
window.console.log('pluginname selection count: ' + $obj.size());
}
};
// define and expose our format function
$.fn.pluginname.methodname = function() {
};
// plugin defaults
$.fn.pluginname.defaults = {
debug: 0
};
})(jQuery);
@monsat
Copy link
Author

monsat commented Jul 16, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment