I wanted to know how to access a particular column of a table.
Suppose the table has the following columns.
Name University Age Grades
Now, I want to access the cells of the Age column.
I have this piece of code, but I'm not able to access the column i want to access.
Expand|Select|Wrap|Line Numbers
- function ShowLogs(opt, num)
- {
- var tab = document.getElementById('Table');
- var numRows = tab.children.length;
- var tabChild = tab.firstChild;
- for (var i = 0; i < numRows; i++) {
- tabChild.style.display = '';
- if (opt.value != 'All' && tabChild.id != opt.value) {
- tabChild.style.display = 'none';
- }
- tabChild = tabChild.nextSibling;
- }
- }
[HTML]<tbody id="Table">
<table border="1">
<tr>
<td>Name</td><td>Uni</td><td>Age</td><td>Grades</td>
</tr>
<tr>
<td>A</td>
<td>DSFSDF</td>
<td>45</td>
<td>SDFSD</td>
</tr>
<tr>
<td>B</td>
<td>DSFSDF</td>
<td>23</td>
<td>SDFSD</td>
</tr>
</table>
</tbody>
[/HTML]
Can Any1 help me with this problem?
Thanks,
Ravi