I'm looking at an example on this Getting value from table cell in javascript...not jquery page where someone showed how to grab text from a table in JavaScript:
var refTab=document.getElementById("ddReferences")
var ttl;
// Loop through all rows and columns of the table and popup alert with the value
// /content of each cell.
for ( var i = 0; i<refTab.rows.length; i++ ) {
var row = refTab.rows.item(i);
for ( var j = 0; j<row.cells.length; j++ ) {
var col = row.cells.item(j);
alert(col.firstChild.innerText);
}
}
I'm wondering, if I wanted to simply grab the text in the cell of row 1, column 1, could I not do the following? If not, why not?
var myText = document.getElementById("ddReferences").rows.item(0).cells.item(0).firstChild.innerText;
It doesn't work when I try it in my webpage I'm trying to create. (Yes, I'm aware of a thing called JQuery. I know someone is going to tell me to learn it. Maybe I will some day.)