VellAnaexia
New Member
I am extracting data from HTML table. I have separated heading and tr data into 2 arrays,suppose I have table :\[code\]<table cellpadding="0" cellspacing="0" border="0" class="display dTable messageinbox"> <thead> <tr> <th>ID</th> <th align="left">Name</th> <th align="left">Message</th> </tr> </thead> <tbody> <tr> <td align="center" style="vertical-align:middle">1</td> <td align="left" style="vertical-align:middle">Ashfaq </td> <td align="left" style="vertical-align:middle">hi </td> </tr> <tr> <td align="center" style="vertical-align:middle">2</td> <td align="left" style="vertical-align:middle">Adam </td> <td align="left" style="vertical-align:middle">test </td> </tr> </tbody></table>\[/code\]Here is my code :\[code\]$("#ExportOption").click(function() { var $table = $("table:first"), $headerCells = $table.find("thead th"), $rows = $table.find("tbody tr"); var headers = [], rows = []; $headerCells.each(function(k,v) { headers[headers.length] = $(this).text().replace(',', ''); }); $rows.each(function(row,v) { $(this).find("td").each(function(cell,v) { if(typeof rows[cell] === 'undefined') rows[cell] = []; //alert($(this).parent().find("tr")); rows[row][cell] = $(this).text().replace(',', ''); }); }); alert(headers); alert(rows); });\[/code\]This give me output like this \[code\] Heading : ID Name Message Rows : 1 Ashfaq hi 2 Adam test\[/code\]The output I want is to just add a line separator between the each \[code\]tr\[/code\] data like\[code\]1 Ashfaq hi \Separator 2 Adam test\[/code\]