Retrieve input id from label
You can simply use the htmlForlabel property to refer to the text field:
$('label').text(function() {
// find tag by id and return its value
return $('#' + this.htmlFor).val();
});
After reading the question again, you can only look for this:
$('label').text(function() {
return 'input#' + this.htmlFor;
});
See also: label
The way you form a dynamic selector inside a receiver function is completely wrong,
Try
$('label').text(function(){
return $('#' + $(this).attr('for')).val();
});
Or, if your original HTML structure is the same as the specified structure, you can use .next(),
$('label').text(function(){
return $(this).next('input').val();
});