There begin to appear some answers that assume you want to get all <td>
elements from #table
. If so, the simplest cross-browser way how to do this is document.getElementById('table').getElementsByTagName('td')
. This works because getElementsByTagName
doesn't return only immediate children. No loops are needed.