JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li id="foo">foo</li>
<li id="bar">bar</li>
</ul>
JavaScript
jQuery.fn.outerHTML = function(s) {
return s
? this.before(s).remove()
: jQuery("<p>").append(this.eq(0).clone()).html();
};
alert($('li').map(function () { return $(this).outerHTML(); }).get());