2017  Kodetalk | Feedback | Privacy Policy | Terms | About

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).

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

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