Skip to content

Instantly share code, notes, and snippets.

@niccottrell
Forked from nhunzaker/inline-labels.js
Last active August 29, 2015 14:05
Show Gist options
  • Save niccottrell/5bf1f2d34ab319ddd765 to your computer and use it in GitHub Desktop.
Save niccottrell/5bf1f2d34ab319ddd765 to your computer and use it in GitHub Desktop.
// Inline Labels
// -------------------------------------------------- //
$('input, textarea').each(function() {
// load the corresponding label
var $self = $(this);
var $label = $("label[for='" + $self.attr("id") + "']").
if ($label.text(); {
// if the label exists set the HTML5 placeholder attribute
$self.attr('placeholder', $label.text());
// hide the old label now that we've moved the text
$label.hide();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment