jQuery插件模板
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery插件模板相关的知识,希望对你有一定的参考价值。
Pretty straight forward. Replace 'PLUGIN_NAME' with the name of your plugin, add your code in the appropriate places, test and deploy.Should be pretty easy to use, I commented it heavily.
// Create Closure (function($) { $.fn.PLUGIN_NAME = function(options) { // Extend the defaults, over-writing them with anything passed by the caller var opts = $.extend({}, $.fn.PLUGIN_NAME.defaults, options); // Iterate over each element return this.each(function() { $this = $(this); // Allow for use of the Metadata plugin var o = $.meta ? $.extend({}, opts, $this.data()) : opts; // YOUR CODE GOES HERE }); }; // Additional methods follow the format: // $.fn.PLUGIN_NAME.format = function(txt) { // FUNCTION STUFF GOES HERE // }; // Plugin Defaults $.fn.PLUGIN_NAME.defaults = { }; })(jQuery); // Closure Closed
以上是关于jQuery插件模板的主要内容,如果未能解决你的问题,请参考以下文章