Skip to content

Instantly share code, notes, and snippets.

@barlas
Last active August 29, 2015 14:10
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 barlas/9f21548da499080475cb to your computer and use it in GitHub Desktop.
Save barlas/9f21548da499080475cb to your computer and use it in GitHub Desktop.
jQuery - Placeholder fix for older browsers.
$('*[placeholder]').val(function () { return $(this).prop('placeholder')});
$(document).on('focus', '[placeholder]',function(){
$(this).val() == $(this).prop('placeholder') ? $(this).val('') : '';
});
$(document).on('blur', '[placeholder]',function(){
$(this).val() == '' ? $(this).val($(this).prop('placeholder')) : '';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment