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> <p>some text</p> <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.