JSFiddle - React, Tailwind, and code Playground

HTML

<span class="a-selector" type="submit" value="Submit Me">This <code>span</code> will become an <code>a</code>nchor</span>
<br />
<br />
<span class="a-selector" type="submit" value="Submit you">This <code>span2</code> will become an <code>a2</code>nchor</span>
<br />
<a class="click-me" href="#">Click to change</a>

CSS

span.a-selector {
    color: red;
}

a.a-selector {
    color: green;
}

JavaScript

$('.click-me').click(function() {
    var newElement = $('.a-selector').get(0).outerHTML.replace(/^<span/, "<a").replace(/<\/span>$/, "</a>");
    $('.a-selector').replaceWith(newElement);
});