JSFiddle - React, Tailwind, and code Playground
HTML
<img src="_images/hockey.png" />
<img src="_images/himalaya.png" alt="Himalaya Picture"/>
JavaScript
$('img').each(function(i) {
if ($(this).prop('alt')) {
console.log($(this).prop('alt') + ' on element ' + i);
} else {
//code for when it has no alt
}
});