Skip to content

Instantly share code, notes, and snippets.

@zurie
Created February 19, 2015 15:23
Show Gist options
  • Save zurie/ae13761985eba328dce1 to your computer and use it in GitHub Desktop.
Save zurie/ae13761985eba328dce1 to your computer and use it in GitHub Desktop.
Default Plugin
//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() {
//Iterate over the current set of matched elements
return this.each(function() {
//code to be inserted here
});
}
});
//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