Skip to content

Instantly share code, notes, and snippets.

@Sergic
Created September 7, 2012 00:14
Show Gist options
  • Save Sergic/3661735 to your computer and use it in GitHub Desktop.
Save Sergic/3661735 to your computer and use it in GitHub Desktop.
ie8 html5 placeholder (jquery)
$('input[placeholder]').each(function(){
var input = $(this);
$(input).val(input.attr('placeholder'));
$(input).focus(function(){
if (input.val() == input.attr('placeholder')) {
input.val('');
}
});
$(input).blur(function(){
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.val(input.attr('placeholder'));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment