I am looking for a way to select only images that are inside links, so I can add the rel="lightbox" attribute to those links. I have attempted to achieve this using 2 loops but it is not working as expected because it also adds the rel attribute to normal links without images.
Below is the jQuery code I have tried:
$('#floorplans a img').each(function() {
$(this).parent().attr('rel','lightbox[floorplans]');
});
Any help or suggestions would be greatly appreciated. Thank you.