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>
Written by Jonathan Goode
Related protips
1 Response
Or, you know, use this:
$('selector').get(0).outerHTML
which is supported in modern browsers (IE included).
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Related Tags
#jquery
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#