JSFiddle - React, Tailwind, and code Playground

HTML

<ul>
  <li><img src='http://incursionmorocco.com/test/a/1.jpg'></li>
</ul>
<ul>
  <li><img src='http://incursionmorocco.com/test/b/1.jpg'></li>
</ul>

CSS

img {
  width: 80px;
  height: 80px;
}

JavaScript

$('ul').each(function() {
  for (i = 2; i < 10; i++) {
    image = new Image()
    image.src = $(this).find('img').attr('src').replace(/\d/, i)
    $(image).error(function() {
        //don't do actually anything
      })
      //else, if the img exists append it as a new <li>
  }
})