JSFiddle - React, Tailwind, and code Playground
by skram
HTML
<div id="main">
<p>I am p tag</p>
<span> i am span tag</span>
</div>
JavaScript
$(function() {
jQuery.fn.outerHTML = function(s) {
var _this = this[0];
return _this.outerHTML?_this.outerHTML:(s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html());
};
alert($('#main p').outerHTML());
});