[jQuery] Re: How to use anchor text as title attribute?

2009-03-05 Thread Jonny Stephens
Thanks for pointing out the omission. I'll use this solution as it's more compact. Jonny On Mar 5, 6:49 am, Klaus Hartl wrote: > > $('a').attr('title' , function() { $(this).text() } ); > > > I must be missing something simple here. > > Yes, a return statement. > > $('a').attr('title' , functio

[jQuery] Re: How to use anchor text as title attribute?

2009-03-04 Thread Klaus Hartl
> $('a').attr('title' , function() { $(this).text() } ); > > I must be missing something simple here. Yes, a return statement. $('a').attr('title' , function() { return $(this).text(); }); --Klaus

[jQuery] Re: How to use anchor text as title attribute?

2009-03-04 Thread Jonny Stephens
Many thanks for your quick response Brian. Works fine. Images do produce an empty title string as you predicted. I'm solely targeting text so no problem there. Jonny On Mar 4, 11:27 pm, brian wrote: > $('a').each(function() > { >         $(this).attr('title', $(this).text()); > > }); > > Keep

[jQuery] Re: How to use anchor text as title attribute?

2009-03-04 Thread brian
$('a').each(function() { $(this).attr('title', $(this).text()); }); Keep in mind, though, that an anchor might have an image inside, rather than text. I doubt it'd be an issue. I guess jquery would simply set it to the empty string. On Wed, Mar 4, 2009 at 6:11 PM, Jonny Stephens wrote: