I have a table which has a search field. After searching data, the listed data are to be exported into excel which requires some extra information to be added which is not shown in the table, needs to be pulled from database. So, I need to access all the listed data's id (after seraching). Also the tag has no relevant 'id' or 'class' so that it can be grabbed, since it were rendered using datatables. How can this be achieved using jquery
<table id='mytable' border='1'>
<tr>
<th id='ID'>ID</th>
<th id='Email'>Email</th>
</tr>
<tr>
<td>1</td>
<td>[email protected]</td>
</tr>
<tr>
<td>2</td>
<td>[email protected]</td>
</tr>
<tr>
<td>3</td>
<td>[email protected]</td>
</tr>
</table>
<button id='gen'>Generate excel file</button>
jsfiddle: http://jsfiddle.net/xLA3g/2/
have a look at this, may it helps http://jsfiddle.net/xLA3g/3/
$('#mytable tr th').each(function(i){
alert($(this).text());
});
ANSWER UPDATE, show td column number http://jsfiddle.net/xLA3g/4/
$('#mytable tr td:first-child').each(function(i){
alert($(this).text());
});
let me know if I can help assist any further
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments