What is it I am doing wrong here:
When I try to use the getttribute['id'] method on a TableCell object that I get from iterating through a tables rows/cells it returns undefined:
var rows = document.getElementById["table"].rows;
var cells;
for(var i=0; i < rows.length; i++) {
cells = rows[i].cells
for(var j=0; j < cells.length; j++) {
alert(cells[j].innerHTML); //returns Cell1
alert(cells[j].getAttribute["id"]); //returns undefined
alert(document.getElementById["c1"].innerHTML); //returns Cell1
}
}
This is example HTML:
<table id="table">
<tbody>
<tr>
<td id="c1">Cell1</td>
</tr>
</tbody>
</table>
Question is why does the getAttribute method return undefined for all attributes when accessed through cells[j]?