On Jan 24, 2009, at 12:26 PM, Klaus Hartl wrote:


I assume you use the for attribute to associate labels with their
inputs. Try (of course you need to adapt the selector probably):

$('label').each(function() {
   $('#' + this.htmlFor).val( $(this).text() );
});

--Klaus



Nice one, Klaus!

You could also do it the other way around, iterating through the text inputs instead of the labels:

$('input:text').each(function() {
  $(this).val( $('label[for=' + this.id + ']').text() );
});


--Karl
____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com

Reply via email to