Skip to content

Instantly share code, notes, and snippets.

@logeshpaul
Created March 30, 2012 09:50
Show Gist options
  • Save logeshpaul/2250437 to your computer and use it in GitHub Desktop.
Save logeshpaul/2250437 to your computer and use it in GitHub Desktop.
Modernizer: Placeholder
if(!Modernizr.input.placeholder){
$("input").each(function(){
if($(this).val()=="" && $(this).attr("placeholder")!=""){
$(this).val($(this).attr("placeholder"));
$(this).focus(function(){
if($(this).val()==$(this).attr("placeholder")) $(this).val("");
});
$(this).blur(function(){
if($(this).val()=="") $(this).val($(this).attr("placeholder"));
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment