You can do:
$('#map_canvas > img[alt=""]').each(function() { $(this).attr('alt', $(this).attr('src'); });
This will find all the images in #map_canvas that do not have an alt tag, and then set the alt tag to the same as the src image.
As an alternative, I would recommend:
$('#map_canvas > img[alt=""]').attr('alt', 'Alt text');
Because this will only add alt tags to images that don't have them.
Richard
source share