Sunday, January 25, 2009

[jQuery] Re: How do I show the label text in an input

Thanks for all the responses, much much appreciated.

Funny you mentioned that method Ramanathan, as it's the one I've ended
up using!

Cheers,

osu

On Jan 24, 11:07 pm, Ramanathan RV <ramanatha...@gmail.com> wrote:
> Hi,
>
> Checkout the non-intrusive labelover plugin.http://remysharp.com/2007/03/19/a-few-more-jquery-plugins-crop-labelo...
> It might be very useful when you decide to write client side validation on
> the form.
>
> On Sun, Jan 25, 2009 at 2:14 AM, Karl Swedberg <k...@englishrules.com>wrote:
>
>
>
>
>
> > 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
>
> --
> Thanks
> Ram

No comments: