Skip to content

Instantly share code, notes, and snippets.

View bratsun's full-sized avatar

Max Bratsun bratsun

View GitHub Profile
@bratsun
bratsun / label-to-placeholder.js
Created January 26, 2016 14:46 — forked from makeusabrew/label-to-placeholder.js
Simple jQuery snippet to convert form labels into inline placeholders
$("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();
}
});