Javascript - How to select "x" row

See here for the original answer.

One answer to this question can be found here, if you are only interested in getting the nth row of a table via JavaScript:

var cells = document.getElementById('table').getElementsByTagName('td');

This will contain all your table cells. Use array notation to access a specific one:

cells[4]

Here's a quick demo which changes the background color:

http://jsfiddle.net/jackwanders/W7RAu/


Tags

  1. javascript (Private)
  2. html (Private)
  3. table (Private)
  4. stack-overflow (Private)
  5. answer (Private)