Skip to content

Instantly share code, notes, and snippets.

@KB1RMA
Created March 31, 2014 17:52
Show Gist options
  • Save KB1RMA/9898117 to your computer and use it in GitHub Desktop.
Save KB1RMA/9898117 to your computer and use it in GitHub Desktop.
jQuery plugin to select an element's HTML content **including** the outer HTML.
;(function ($) {
'use strict';
$.fn.outerHTML = function (s) {
return s
? this.before(s).remove()
: $("<p>").append(this.eq(0).clone()).html();
};
}(this.jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment