Skip to content

Instantly share code, notes, and snippets.

@athanassiadis
Created January 12, 2012 15:36
Show Gist options
  • Save athanassiadis/1601153 to your computer and use it in GitHub Desktop.
Save athanassiadis/1601153 to your computer and use it in GitHub Desktop.
Modernizr placeholder
if (!Modernizr.input.placeholder){
$('input[type=text]').each( function(){
$(this).attr('value', $(this).attr('placeholder') )
.focus(
function(){
var ph = $(this).attr('value');
$(this).attr('value','').blur( function(){
if($(this).attr('value').length < 1 ){
$(this).attr('value', ph);
}
})
});
} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment