Last Updated: February 25, 2016
·
696
· u01jmg3

Returns an HTML String of an elements contents plus itself

<script type="text/javascript" charset="utf-8">
jQuery.fn.outerHTML = function(s) {
    return (s) ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html();
}
</script>

1 Response
Add your response

Or, you know, use this:

$('selector').get(0).outerHTML

which is supported in modern browsers (IE included).

over 1 year ago ·