Created
August 19, 2013 13:59
-
-
Save chrisnharvey/6269460 to your computer and use it in GitHub Desktop.
Remove HTML5 placeholders on focus
This file contains 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() { | |
// Remove placeholders on focus | |
$("input, textarea").focus(function() { | |
var placeholder = $(this).attr('placeholder'); | |
if (placeholder !== '') { | |
$(this).attr('placeholder', ''); | |
$(this).attr('data-placeholder', placeholder); | |
} else { | |
$(this).attr('placeholder', placeholder); | |
} | |
}); | |
$('input, textarea').blur(function() { | |
var placeholder = $(this).attr('data-placeholder'); | |
if (placeholder !== '') { | |
$(this).attr('placeholder', placeholder); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment