Skip to content

Instantly share code, notes, and snippets.

@amiel
Created January 22, 2010 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiel/284066 to your computer and use it in GitHub Desktop.
Save amiel/284066 to your computer and use it in GitHub Desktop.
$.fn.tabularosa = function(value) {
this.each(function() {
var self = $(this),
klass = 'tabularosa',
value = value || self.attr('data-tabularosa'),
set_value = function() {
if ($.trim(self.val()) == '' || self.val() == value)
self.val(value).addClass(klass);
},
clear_value = function() {
if (self.val() == value)
self.val('').removeClass(klass);
};
self.focus(clear_value).blur(set_value).blur();
});
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment