Just so you know: there is already a plugin for that.
JQuery UI has a nice learning center.
Basic example from learning center above:
(function ( $ ) {
var shade = "#556b2f";
$.fn.placeholder = function() {
// your code
return this;
};
}( jQuery ));