JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>1</li>
<li><a href="#">2</a></li>
</ul>
JavaScript
$('ul li').each(function() {
if ($(this).find('a').length > 0) {
$(this).text($(this).text());
}
else {
$(this).html($('<a />').attr('href', '#').text($(this).text()));
}
});