Created
May 24, 2011 15:46
-
-
Save jgable/988954 to your computer and use it in GitHub Desktop.
jQuery Plugin Template
This file contains hidden or 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
//You need an anonymous function to wrap around your function to avoid conflict | |
(function($){ | |
//Attach this new method to jQuery | |
$.fn.extend({ | |
//This is where you write your plugin's name | |
pluginName: function(options) { | |
var defaults = { | |
option1: 'someval' | |
}; | |
var options = $.extend(defaults, options); | |
//Iterate over the current set of matched elements | |
return this.each(function() { | |
var o = options; | |
// code to run on each matched element. | |
}); | |
} | |
}); | |
//pass jQuery to the function, | |
//So that we will able to use any valid Javascript variable name | |
//to replace "$" SIGN. But, we'll stick to $ (I like dollar sign: ) ) | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment