[jQuery] Get the HTML of the current node plus its Inner HTML

[jQuery] Get the HTML of the current node plus its Inner HTML


Hi,
I need to get all the TABLE HTML code within the <body> tag for a
content-generating application. I'm trying to use the html() method,
but it only gets the inner HTML. I also tried clone(), but does the
same thing. Or maybe I'm using it wrong. Here's an example to clarify
what I wanted to do:
Input
====================================================
<body>

some text


<table cellpadding="0" cellspacing="0" style="width: 600px;">....</
table>
<div>...</div>
<table cellpadding="0" cellspacing="0" style="width: 400px;">....</
table>
</body>
Output
====================================================
<table cellpadding="0" cellspacing="0" style="width: 600px;">....</
table>
<table cellpadding="0" cellspacing="0" style="width: 400px;">....</
table>
jQuery Code
====================================================
$("body").children().each(function(){
var contentHtml = "";
if(this.nodeName.toLowerCase() == "table")
{
//need to include the <TABLE> code here
contentHtml += $(this).html();
}
});
Thanks in advance.