Skip to content

Instantly share code, notes, and snippets.

@kujon
Forked from athanassiadis/Modernizr placeholder
Created March 7, 2012 23:45
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 kujon/1997336 to your computer and use it in GitHub Desktop.
Save kujon/1997336 to your computer and use it in GitHub Desktop.
JavaScript: Modernizr placeholder
if (!Modernizr.input.placeholder) {
$('[placeholder]').each(function() {
var $self = $(this);
$self.val($self.attr('placeholder'));
$self.focus(function() {
$self.val('');
}).blur(function() {
if($self.val().length < 1) {
$self.val($self.attr('placeholder'));
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment