Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript inserting rel and title attr into anchor tags Re: inserting rel and title attr into anchor tags

#82794
wolfcry911
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…