JSFiddle - React, Tailwind, and code Playground
HTML
Check the console.
JavaScript
var s = '<div><div><a href="link">Link</a><span> Span</span></div></div>';
var $s = $(s);
$s.find("*").not("a,img,br").each(function() {
$(this).replaceWith(this.innerHTML);
});
console.log($s.html());