Skip to content

Instantly share code, notes, and snippets.

@tareiking
Forked from makeusabrew/label-to-placeholder.js
Created April 23, 2014 05:29
Show Gist options
  • Save tareiking/11203646 to your computer and use it in GitHub Desktop.
Save tareiking/11203646 to your computer and use it in GitHub Desktop.
$("form :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment