Skip to content

Instantly share code, notes, and snippets.

@tpae
Created November 5, 2012 02:39
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 tpae/4014995 to your computer and use it in GitHub Desktop.
Save tpae/4014995 to your computer and use it in GitHub Desktop.
jQuery IE Placeholder fix
$('input,textarea').each(function() {
// set this attr placeholder into val, if ie.
if ($.browser.msie) {
if ($(this).val() == '') {
$(this).val($(this).attr('placeholder'));
}
}
}).focus(function() {
if ($.browser.msie) {
if ($(this).val() == $(this).attr('placeholder')) {
$(this).val('');
}
}
}).blur(function() {
if ($.browser.msie) {
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