JSFiddle - React, Tailwind, and code Playground
HTML
<button id="run">toHTMLString()</button>
<p id="test"><span>Test</span></p>
JavaScript
(function($) {
$.fn.extend({
toHTMLString: function() {
return $('<div>').append(this.clone()).remove().html();
}
});
})(jQuery);
$('#run').click(function() {
var htmlString = $('#test').toHTMLString();
alert(htmlString);
});