Created
July 16, 2011 05:34
-
-
Save monsat/1086044 to your computer and use it in GitHub Desktop.
initial of jquery plugin
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($) { | |
$.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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
via. http://www.learningjquery.com/2007/10/a-plugin-development-pattern