I know this is very easy question, but I couldn\'t find the answer anywhere. Only answers are the ones using jQuery, not pure JS. I\'ve tried the code below and it doesn\'t
This d = t.getElementsByTagName("tr") and this r = d.getElementsByTagName("td") are both arrays. The getElementsByTagName returns an collection of elements even if there's just one found on your match.
So you have to use like this:
var t = document.getElementById("table"), // This have to be the ID of your table, not the tag
d = t.getElementsByTagName("tr")[0],
r = d.getElementsByTagName("td")[0];
Place the index of the array as you want to access the objects.
Note that getElementById as the name says just get the element with matched id, so your table have to be like
and getElementsByTagName gets by the tag.
EDIT:
Well, continuing this post, I think you can do this:
var t = document.getElementById("table");
var trs = t.getElementsByTagName("tr");
var tds = null;
for (var i=0; i