2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

Get selected element's outer HTML

I"m trying to get the HTML of a selected object with jQuery. I need the HTML including the selected object (a table row in this case, where .html()only returns the cells inside the row).

userimage
(function($) {
  $.fn.outerHTML = function() {
    return $(this).clone().wrap('<div></div>').parent().html();
  };
})(jQuery);

And use it like this: $("#myTableRow").outerHTML();
Answer is