Skip to content

Instantly share code, notes, and snippets.

@ejholmes
Created February 29, 2012 20:52
Show Gist options
  • Save ejholmes/1944274 to your computer and use it in GitHub Desktop.
Save ejholmes/1944274 to your computer and use it in GitHub Desktop.
Snippet of javascript for pseudo HTML5 placeholder.
$(function() {
$('.placeholder input[type=text]').each(function() {
var placeholder = $(this).val();
$(this).focus(function() {
if ($(this).val() == placeholder) {
$(this).val('');
}
});
$(this).blur(function() {
if ($(this).val() == '') {
$(this).val(placeholder);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment