Last active
September 25, 2017 15:14
-
-
Save hughshen/aa02c7c247f3d3a6129fc3676c4e179e to your computer and use it in GitHub Desktop.
Auto-hide placeholder text upon focus css and jquery. https://stackoverflow.com/questions/9707021/how-do-i-auto-hide-placeholder-text-upon-focus-using-css-or-jquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input:focus::-webkit-input-placeholder, | |
input:focus:-moz-placeholder, /* FF 4-18 */ | |
input:focus::-moz-placeholder, /* FF 19+ */ | |
input:focus:-ms-input-placeholder, /* IE 10+ */ | |
textarea:focus::-webkit-input-placeholder, | |
textarea:focus:-moz-placeholder, | |
textarea:focus::-moz-placeholder, | |
textarea:focus:-ms-input-placeholder { | |
color: transparent; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($) { | |
$('input, textarea').focus(function () { | |
$(this).data('placeholder', $(this).attr('placeholder')).attr('placeholder', ''); | |
}).blur(function () { | |
$(this).attr('placeholder', $(this).data('placeholder')); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment