tags:

views:

570

answers:

2

I'm trying to get the HTML of a selected object with jQuery. I am aware of the .html() function, the issue is that I need the HTML including the selected object (a table row in this case, where .html() only returns the cells inside the row). I've search around and found a few very 'hackish' type methods of cloning an object, adding it to a newly created div, etc, etc, but this seems really dirty. Is there any better way, or does the new version of jQuery (1.4.2) offer any kind of 'outerHtml' functionality?

Thanks!

A: 
$("#myTable").parent().html();

Perhaps I'm not understanding your question properly, but this will get the selected element's parent element's html.

Is that what you're after?

inkedmn
Acually no, because if that parent has other children he'll get that html too.
David V.
...what he said. I'm looking for the element itself, not it and all its parent's other children. How did this get two up votes???
Ryan
+1  A: 

This site seems to have a solution for you : outer html

David V.
I saw this but was trying to avoid it because it seemed to hackish and like there should have been a better way, but it works well. Thanks.
Ryan