Skip to content

Instantly share code, notes, and snippets.

@muhittin
Created August 8, 2012 11:08
Show Gist options
  • Save muhittin/3294314 to your computer and use it in GitHub Desktop.
Save muhittin/3294314 to your computer and use it in GitHub Desktop.
placeholder attribute for IE Javascript Hack
$(document).ready(function(){
$("input[placeholder], textarea[placeholder]").each(function(i, e){
if($(e).val() == "")
{
$(e).val($(e).attr("placeholder"));
}
$(e).blur(function(){
if($(this).val()=="")
$(this).val($(e).attr("placeholder"));
}).focus(function(){
if($(this).val() == $(e).attr("placeholder"))
$(this).val("");
});
});
});
@kavivel316
Copy link

This is super. Works fine. Great!

@pophils
Copy link

pophils commented Oct 7, 2016

Works fine, thanks.

@gedankennebel
Copy link

Doesn´t work for input type=password :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment