[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

[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 bally.z...@gmail.com wrote: $('a').each(function() {         $(this).attr('title', $(this).text());

[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