Skip to content

Instantly share code, notes, and snippets.

@fixlr
Created September 29, 2010 18:38
Show Gist options
  • Save fixlr/603283 to your computer and use it in GitHub Desktop.
Save fixlr/603283 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$('.labels-inside input[type="text"]').add('.labels-inside textarea').each(function() {
var label = $(this).prev('label[for="'+$(this)[0].id+'"]').hide().html();
$(this).focus(function() {
if ($(this).val() == label) {
$(this).val('').removeClass('description');
}
});
$(this).blur(function() {
if ($(this).val() == '') {
$(this).val(label).addClass('description');
}
});
$(this).blur();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment