Skip to content

Instantly share code, notes, and snippets.

@mirontoli
Forked from athanassiadis/Modernizr placeholder
Created March 25, 2012 22:50
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 mirontoli/2200582 to your computer and use it in GitHub Desktop.
Save mirontoli/2200582 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