Posted By

tommy_b on 01/19/10


Tagged

plugin jquery


Versions (?)

Code stub for new jQuery plugin


 / Published in: jQuery
 

URL: http://addictedtonew.com/archives/414/creating-a-jquery-plugin-from-scratch/

  1. (function($) {
  2. $.fn.myCustomPlugin = function(options) {
  3. var opts = $.extend({}, $.fn.toggler.defaults, options);
  4.  
  5. return this.each(function() {
  6. // apply plugin functionality to each element
  7. // access defaults/options via: opts.customValue
  8. });
  9.  
  10. function customFunction(){
  11. // this function can be called from within the this.each statement
  12. }
  13. }
  14. $.fn.toggler.defaults = {customValue: false}
  15. })(jQuery);
  16.  
  17.  
  18. // call using this syntax
  19. $('.elementToSelect').myCustomPlugin({customValue:true});

Report this snippet  

You need to login to post a comment.