how wud u get the next row in the following example? (i am trying to print the next three row/column values of the rowId provided)
function printRowData(rowId)
{
var row=document.getElementById(rowId);
for(i=0; i<3 ; i++)
{
var column=row.getElementsByTagName("td");
alert(column[0].innerText);
//now i want to move to the next row...something like row=row.next()?????
}
}
If you just want the next row, and not subsequent rows, you can do this:
So your code could look like this:
From the current row, it gets the
.parentNode, then from that, it accesses therowscollection, and increments the.rowIndexproperty of the original row to select the next.This takes care of white space issues.
Notice also that instead of
getElementsByTagName, I replaced it withrow.cells, which is a collection of the cells in the row.EDIT: Forgot to include the
rowsproperty afterparentNode. It was included in the description though. Fixed.