[jQuery] Moving label text to input
Hi,
I have this small script that moves the text from a label and places
it in a input field next to the label, like such:
function moveLabelToInput(){
$("label.moveToInput").each(function(){
var lblText = $(this).text();
$(this).hide()
.next("#" + $(this).attr("for"))
.attr({title: lblText})
.focus(function(){
if ($(this).val() === lblText) {
$(this).val("");
}
})
.blur(function(){
if($(this).val() === "") {
$(this).val(lblText);
}
})
.val(lblText);
});
}
However, I want to change this: .next("#" + $(this).attr("for")) so it
can find a input field anywhere in the document and not just next to
the label.
How can I do that?
regards / Emil