Skip to content

Instantly share code, notes, and snippets.

@gregorymostizky
Created April 13, 2011 13:42
Show Gist options
  • Save gregorymostizky/917562 to your computer and use it in GitHub Desktop.
Save gregorymostizky/917562 to your computer and use it in GitHub Desktop.
Adding custom function to JQuery
// definition
$.fn.customFunction = function(options) {
var defaults = {
width: 650,
height: 450
};
var opts = $.extend(defaults, options);
var self = $(this[0]); // if working on first/single element
// functionality here
self.css('color','red');
}
// usage
$('#mydiv').customFunction({color:'green'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment