Skip to content

Instantly share code, notes, and snippets.

@overbalance
Created November 21, 2011 21:05
Show Gist options
  • Save overbalance/1383929 to your computer and use it in GitHub Desktop.
Save overbalance/1383929 to your computer and use it in GitHub Desktop.
placeholder placeholder
if (!Modernizr.input.placeholder){
$('input[placeholder],textarea[placeholder]').each(function(){
var input = $(this);
if (!input.attr('placeholder')) return;
var ph = input.attr('placeholder');
input.val(ph);
input.focus(function(){
if (input.val() == ph) input.val('');
});
input.blur(function(){
if (input.val() == '') input.val(ph);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment