Home › Forums › JavaScript › inserting rel and title attr into anchor tags › Re: inserting rel and title attr into anchor tags
July 3, 2011 at 10:01 pm
#82794
Participant
your comment just made me realize you don’t even need the variable
$('#gallery a').each(function(){
$(this).attr('title',$(this).children('img').attr('title'));
});
This will work (not throw an error) even if the anchor has no image as a child, or has a different child element, or the image has no title…