Home › Forums › JavaScript › inserting rel and title attr into anchor tags › Re: inserting rel and title attr into anchor tags
July 3, 2011 at 9:21 pm
#82792
Participant
the .attr method will get the attribute from only the first element in the selection
there may be a better way, but I believe this works:
$('#gallery a').each(function(){
imgtitle = $(this).children('img').attr('title'),
$(this).attr('title',imgtitle);
});