I'm working on a way to export some tabular data from an HTML page to Excel using a program called DocRaptor. I'm using PHP to pass the data using their API which then converts the data to an Excel Spreadsheet.
I can't however seem to pass the whole table (including the opening <table>
and closing </table>
tags.
Say for example if I have the following table in HTML:
<table id="placement-table">
<tr id="row">
<td id="cell">Text1</td>
</tr>
<tr id="row1">
<td id="cell">Text2</td>
</tr>
<tr id="row2">
<td id="cell">Text3</td>
</tr>
<tr id="row3">
<td id="cell">Text4</td>
</tr>
</table>
Now for example if I use console.log($('#placement-table').html());
I only get the following output:
<tbody><tr id="row">
<td id="cell">Text1</td>
</tr>
<tr id="row1">
<td id="cell">Text2</td>
</tr><tr id="row2">
<td id="cell">Text3</td>
</tr><tr id="row3">
<td id="cell">Text4</td>
</tr>
</tbody>
Why am I missing the actual opening and closing <table></table>
tags? Is it because .html()
only gives you the content inside of the given element? I realise I'm only logging the info to the Console but I'm just doing this so I can see what's being passed and hence why I noticed it was missing these tags.
Hope this makes sense, if not I can update the question!