JSFiddle - React, Tailwind, and code Playground
HTML
<div id="someDiv">
<p>This is some other HTML I don't care about</p>
<a href="http://site.example">This is an anchor I want to disable</a>
</div>
<button id="myButton">Change my link to a span</button>
JavaScript
function aToSpan() {
var link = $('a');
//Note adding the link to a separate element removes it from the live DOM
var linkHTML = $(document.createElement('p')).append(link).html();
var spanHTML = linkHTML.replace('<a', '<span').replace('a>', 'span>');
$('#someDiv').append(spanHTML);
}
$(function() {
$('#myButton').click(aToSpan);
});