dio-v
12/4/2013 - 6:09 AM

Convert Form Labels into inline Placeholders with jQuery

Convert Form Labels into inline Placeholders with jQuery

$("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();
}