Convert Form Labels into inline Placeholders with jQuery

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

Source