JSFiddle - React, Tailwind, and code Playground

HTML

<span class="test">143</span>
<span class="test">987</span>

CSS

span { border: 1px solid blue; }
img { border: 1px solid red; margin: 10px; }

JavaScript

var string = $(".test").text(),
    digits = string.match(/\d/g)
    htm = [];

for (var i=0, l=digits.length; i<l; i++ ){
    htm.push('<img src="'+digits[i]+'.png" alt="" />');
}
    
$(".test").html( htm.join('') );