/ Published in: jQuery
URL: http://addictedtonew.com/archives/414/creating-a-jquery-plugin-from-scratch/
Expand |
Embed | Plain Text
(function($) { $.fn.myCustomPlugin = function(options) { var opts = $.extend({}, $.fn.toggler.defaults, options); return this.each(function() { // apply plugin functionality to each element // access defaults/options via: opts.customValue }); function customFunction(){ // this function can be called from within the this.each statement } } $.fn.toggler.defaults = {customValue: false} })(jQuery); // call using this syntax $('.elementToSelect').myCustomPlugin({customValue:true});
You need to login to post a comment.
