360935 (3) [Avatar] Offline
#1
In example code
$('img[alt]').each(function(){
  $(this).replaceWith('<span>' + $(this).attr('alt') + '</span>');
});

the .each() seems redundant.

We can write
$('img[alt]').replaceWith(function(){
 return '<span>' + $(this).attr('alt') + '</span>';
});
AurelioDeRosa (20) [Avatar] Offline
#2
Hi.

You're right in saying that the code could have been written as you suggested, which is slightly shorter.

Thank you for taking the time to comment.